dpnzf48660 2017-02-25 06:20
浏览 84
已采纳

在php页面中回显输入字段值

NEW CODE FROM YOUR SUGGESTIONS (STILL NOT WORKING) I am trying to get values from an registration form to a php page with the post method and then echo it in that page so I know it works. If it does I will try to get all the values and insert them into my user table. I dont mind the sql injection risks and that I have to clean the input for now I just want to make it work. But it doesnt, do you guys see what I do wrong? Also is it possible to instead get all the values in an array and post them so I dont have to use so many variables.

 form.php (another page)
<?php include_once("connect.php"); ?>
<?php include_once("getTrycksaker.php"); ?>
<?php include_once("header.php"); ?>
<!-- BUILD COLUMN SYSTEM FOR CROSSDEVICE USABILITY -->
<div class="container">
<div class="row">
    <div class="col-md-1 col-sm-0 col-xs-0"></div>
    <div class="col-md-10 col-sm-12 col-xs-12">
        <h3 class="title">&nbsp;Registrering Företagskonto</h3><hr>
        <div class="alert alert-info" role="alert">Ange vänligen inloggningsuppgifter samt namn och telefonnummer till företagets kontaktperson.</div>
    </div>
    <div class="col-md-1 col-sm-0 col-xs-0"></div>
</div>
<div class="row">
    <div class="col-md-1 col-sm-0 col-xs-0"></div>
    <form class="form" method="post" id="compReg">
        <div class="col-md-5 col-sm-12 col-xs-12">
            <div class="input-group">
                <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                <input type="text" name="name" id="name" class="form-control" placeholder="Kontaktperson"></div><br>
            <div class="input-group">
                <span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
                <input type="email" name="email" id="email" class="form-control" placeholder="E-postadress"></div><br>
            <div class="input-group">
                <span class="input-group-addon"><span class="glyphicon glyphicon-earphone"></span></span>
                <input type="text" class="form-control" placeholder="Telefon"></div><br>
        </div>
        <div class="col-md-5 col-sm-12 col-xs-12">
            <div class="input-group">
                <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
                <input type="password" name="password" id="password" class="form-control" placeholder="Lösenord"></div><br>
            <div class="input-group">
                <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
                <input type="password" name="cpassword" id="cpassword" class="form-control" placeholder="Upprepa Lösenordet"></div><br>
        </div>
        <div class="col-md-1 col-sm-0 col-xs-0"></div>
</div>
<div class="row">
    <div class="col-md-1 col-sm-0 col-xs-0"></div>
    <div class="col-md-10 col-sm-12 col-xs-12">
        <br><div class="alert alert-info" role="alert">Ange vänligen företagets namn, postadress samt organisationsnummer. Avvikande leveransadresser kan registreras vid order.</div>
    </div>
    <div class="col-md-1 col-sm-0 col-xs-0"></div>
</div>
<div class="row">
    <div class="col-md-1 col-sm-0 col-xs-0"></div>
    <div class="col-md-5 col-sm-12 col-xs-12">
        <div class="input-group">
            <span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
            <input type="text" class="form-control" placeholder="Företagsnamn"></div><br>
        <div class="input-group">
            <span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
            <input type="text" class="form-control" placeholder="Organisationsnummer"></div><br>
        <div class="input-group">
            <span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
            <input type="text" class="form-control" placeholder="Gatuadress"></div><br>
    </div>
    <div class="col-md-5 col-sm-12 col-xs-12">
        <div class="input-group">
            <span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
            <input type="text" class="form-control" placeholder="Postnummer"></div><br>
        <div class="input-group">
            <span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
            <input type="text" class="form-control" placeholder="Postort"></div><br>
        <div class="input-group">
            <span class="input-group-addon"><span class="glyphicon glyphicon-paperclip"></span></span>
            <input type="text" class="form-control" placeholder="Eventuell c/o adress"></div><br>
    </div>
    <div class="col-md-1 col-sm-0 col-xs-0"></div>
</div>
<div class="row">
    <div class="col-md-1 col-sm-0 col-xs-0"></div>
    <div class="col-md-10 col-sm-0 col-xs-0">
        <label class="btn btn-info btn-file">Skapa Konto &nbsp;&nbsp;&nbsp;<input id="submitBtn" onclick="rAlert('Go')" type="submit" style="display: none;"><span class="glyphicon glyphicon-ok-sign" ></span></label>
        <br><br><br>
    </div>
    </form>
    <div class="col-md-1 col-sm-0 col-xs-0"></div>
</div>
<?php include_once("footer.php"); ?>


process.php (another page)
<?php print_r($_POST);?>
  • 写回答

3条回答 默认 最新

  • drt3751 2017-02-25 06:27
    关注

    You can get the values using element name.All the values are inside $_POST Array.Just print_r($_POST).You will see all the posted values.

    In process.php;

    extract($_POST);
    echo $name;//prints name
    echo $email;//prints email
    

    The extract() function imports variables into the local symbol table from an array.This function uses array keys as variable names and values as variable values. For each element it will create a variable in the current symbol table.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog