1.

Solve : PHP form saving values to variables?

Answer»

Hey guys,

I really nee your help with this simple piece of code that has gotten the better of me. I want to save the form data to variables to display on the same PAGE when echo is used.

Here's my HTML code:

Code: [Select]<form ACTION="<?php $_SERVER['PHP_SELF'] ?>?savedata=1" name="sgfrm" method="POST" id="sgfrm" onSubmit="javascript:return validate();" enctype="TEXT/plain">
  <input type="hidden" name="flag" value="signup">
                        <table width="90%" border="0" align="center" CELLPADDING="5" cellspacing="5" class="bodytext" >
                          <tr>
                            <td width="30%">&nbsp;</td>
                            <td width="4%">&nbsp;</td>
                            <td width="66%"><DIV align="left"><span class="small_red">
                              <? if($errmsg!='') { ?>
                              <?=$errmsg?>
                              <? }  ?></span>
                               </div></td>
                          </tr>
                          <tr>
                            <td>Firstname<font color="#FF0000">*</font></td>
                            <td>:</td>
                            <td><input name="firstname" type="text" /></td>
                          </tr>
                          <tr>
                            <td>Lastname<font color="#FF0000">*</font></td>
                            <td>:</td>
                            <td><input name="lastname" type="text" class="textfield"  id="lastname" value="<?=stripslashes($_POST['lastname'])?>" /></td>
                          </tr>
                          </table>
                       </form>     
And here's my PHP code:

Code: [Select]<?php 
        $savedata = $_REQUEST['savedata'];
        if ($savedata == 1)
        {
        $firstname = $_GET["firstName"];
        echo "*** ".$firstname;
        }
        ?>
I know its a simple mistake but I cannot seem to find it.

PLEASE HELP!!  Code: [Select]<form action="<?php echo $_SERVER['PHP_SELF'] ?>?savedata=1"
You forgot the "echo".



Discussion

No Comment Found