...

View Full Version : How to mantain information?



farid
06-29-2005, 10:57 PM
Hi y'all!!

Well, I have one page with some text boxes, and a submit button, the thing is that when they hit the submit button and enter to the next page they can go back and modify the data they have entered and not enter the whole information again.

Hope someone can help me :(

Thanks!!

chump2877
06-29-2005, 11:23 PM
Use some simple PHP validation on your text boxes so that important fields cannot be skipped over by the user and/or your text boxes only accept certain kinds of responses....something similar to this (you would need to change the variable names and the conditions of the IF statements):


$errors = 0;


if (empty($first_name))
{
echo "<br><b>First Name</b> is a required field.";
$errors++;
}

if (empty($last_name))
{
echo "<br><b>Last Name</b> is a required field.";
$errors++;
}

if (empty($email))
{
echo "<br><b>E-mail</b> is a required field.";
$errors++;
}

if (empty($confirm_email))
{
echo "<br><b>Confirm E-mail</b> is a required field.";
$errors++;
}

if ($email != $confirm_email)
{
echo "<br><b>E-mail</b> was entered incorrectly.";
$errors++;
}


if ($errors > 0)
{
echo "<br><br>Please use your browser's back button to return to the form and fix any errors. <i>Thank you!</i><br><br>";
exit();
}

bfsog
06-29-2005, 11:25 PM
For this I assume your are POSTING the data and not GETTING it..




<form name="form_name" method="post" action="somefile.php">

<input type="text" name="some_name" value="<?php if (isset($_POST['some_value']) echo $_POST['some_value'];?>" />

</form>



You would replicate for all your form elements

* edit: what this does is when the page loads it checks for the form values, to see if they are set. If they are, it displays the value.

chump2877
06-29-2005, 11:32 PM
Oops, yes do it bfsog's way, and also throw in a condition in there that states if the textbox value is set, then the textbox should be "greyed out" and "uneditable" (i can't remember how to do this....Google for it and find out)

bfsog
06-29-2005, 11:46 PM
Thanks chump.

Hm, to make it read only, try



<form name="form_name" method="post" action="somefile.php">

<input type="text" name="some_name" value="<?php if (isset($_POST['some_value']) { echo $_POST['some_value'];?>" readonly="readonly" <?php } ?> />

</form>


What that does is the same except, if the form value is set, it echo's the value and sets readonly to true.

chump2877
06-30-2005, 02:04 AM
Actually, I think it would read like this?



<form name="form_name" method="post" action="somefile.php">

<input type="text" name="some_name" value="<?

if (isset($_POST['some_value']))
{
echo $_POST['some_value'];
}

?>" <?

if (isset($_POST['some_value']))
{
print 'readonly="readonly"';
}

?>>

</form>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum