Jump to content
Killersites Forums

PHP form problem


Recommended Posts

Hi all,

 

I'm having a complete mind blank, sure there is a very simple answer to my soloution, but i just can't find it!

 

Basically i have a registration form. When submitting the form goes to another page to process the information. It successful the info will be entered into the database and the user is redirected to the login page. If there is a problem with the data supplied, e.g. the username chosen has already been taken the page will redirect back to the registration form. What i'm trying to do it make it so the form is automatically filled in with what the user previously entered if that makes sense. If anyone knows how to do this i would be very greatful!

 

Thanks,

 

pb1uk

Link to post
Share on other sites

The way I usually handle that is to use several temporary variables. I'll initially set them to be an empty string, and then when the form is processed, set their values using $_POST[]. For example:

<?php

// set variables to blank string
$temp = '';


if (isset($_POST['submit']))
{
   // process script
   $temp = $_POST['temp'];
}
?>

<form action="" method="POST">
<input name="temp" type="text" value="<?php echo $temp' ?>">
<input type="submit" name="submit">
</form>

I usually combine my processing script and my form view like you see above, so one file handles everything, or I will make the processing file the "main" file, and use an include to include the form as necessary.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...