Set html text box value from php variable -


I am trying to fill a 'default' value for text box in an HTML registration form based on session data I am

If a user generates an error on my registration form, then it is sent back to them, and I want them to fill as much as possible to fill their data as much as possible. Send it in plain form to start with.

Here is my handler script checking:

  // Get text from the IA text. $ Username = mysql_real_escape_string ($ _ POST ['username']); $ Password = mysql_real_escape_string ($ _ POST ['password']); $ Password_check = mysql_real_escape_string ($ _ POST ['pwcheck']); $ Email = mysql_real_escape_string ($ _ POST ['email']); $ Spam_check = mysql_real_escape_string ($ _ POST ['check']); // Spam check IP = $ _SERVER ['REMOTE_ADDR']; // Log in Set up some session data for your IP // unixtacks or spam or errors $ _SESSION ['Username'] = $ username; $ _SESSION ['email'] = $ email; // Check the blank information ($ username == NULL || $ username == '') {// no username set header ("location: register.php? P = un"); Die; } If ($ password == faucet || $ password == '') {// set a password header ("location: register.php? P = pw"); Die; } If ($ password_check == NULL || $ password_check == '') {// set a password check header ("location: register.php? P = pwchk"); Die; } If ($ email == tap = $ email == '') {// no email set header ("location: register.php? P = em"); Die; } // Do we have spam? If (strlen ($ spam_check) & gt; 0) {// spam bot alert header ("location: http://www.google.co.uk"); Die ('you' are naughty. '); } // Does the password and check match? If ($ password! = $ Password_check) {// no match $ _SESSION ['username'] = $ username not; $ _SESSION ['email'] = $ email; Header ("Location: register.php? P = pwnpc and email =". $ Email ""); Die; }   

and on my Forms page I am:

  // Check the empty field and session data if (isset ($ _ session [ 'Email'])) {// email session data set $ email_value = 'value = "'. $ _ Session ['email']. ' '';} And {$ email_value = 'placeholder = "email"';} $ Errors = mysql_real_escape_string ($ _GET ['p']); switch ($ errors) {// some empty case is "un": // No username set $ pen_name = 'pen name is missing!'; Break; case "pw": // no username set password password = 'password is missing!'; Break; case "pwkk": // No password checks set $ pw_check = 'Your password don' t match! '; Break; case "em": // no user name set $ email =' email missing! '; Breakdown; "Pwnpc": // password $ pw_mismatch = 'password does not match password'! '; Break;}   

and its own form

  & lt; form action = "register_handle.php" method = "post" & gt; & gt; Label & gt; select a pen name & lt; / label & gt; & lt; br / & gt; Lt ;? php echo $ pen_name? & Gt; & lt; p & gt; input type = "article" name = "username" placeholder = "pen name" autofocus required & gt; & lt; / p & Gt; & lt; Label & gt; Select a password & lt; / label & gt; & lt; Br / & gt; & Lt; P & gt; & Lt; Input type = "password" name = "password" placeholder = "password" required & gt; --- & gt; & Lt; Input type = "password" name = "pwcheck" placeholder = "confirm password" required & gt; & Lt ;? Php ek $ password $ Pw_check $ Pw_mismatch? & Gt; & Lt; / P & gt; & Lt; Label & gt; Email & lt; / Label & gt; & Lt; Br / & gt; & Lt ;? Php email echo $ email? & Gt; & Lt; P & gt; & Lt; Input type = "email" name = "email" & lt ;? Php echo $ email_value? & Gt; Required & gt; & Lt; / P & gt; & Lt; Input id = "checkit" type = "text" name = "checkit" maxlength = "50" size = "30" & gt; & Lt; Input type = "submit" value = "sign me up" name = "submit" class = "submit" & gt; & Lt; / Form & gt;   

But I can not get back the value. I'm sure it should be simple, but can you see a problem here? As you can see that I have tried only on the TRE email box, but no benefit till now.

You are missing in your area:

  & lt ; P & gt; & Lt; Input type = "email" name = "email" value = "& lt ;? php echo htmlentities ($ email_value)? & Gt;" placeholder = "email" requires & gt; & Lt; / P & gt;   

This will break the placeholder that you wanted to use, but it should always be anyway, because it will not provide any value because it will not be displayed.

Comments