By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 697 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

Display and check entered data before submission

P: 58
Greetings !
Can anyone share me some piece of code that displays user submitted data for another chance to verify and correct it before finally inserting it into the database? If insertion cannot be prevented at this level,how do i go about turning the displayed page into an updating rather than inserting page?
Thank you for your help !
May 28 '07 #1
Share this Question
Share on Google+
6 Replies


ak1dnar
Expert 100+
P: 1,584
Greetings !
Can anyone share me some piece of code that displays user submitted data for another chance to verify and correct it before finally inserting it into the database? If insertion cannot be prevented at this level,how do i go about turning the displayed page into an updating rather than inserting page?
Thank you for your help !
How do you want to display the submitted values(Before Inserting to database),in the same page or in a different page.
May 28 '07 #2

P: 58
How do you want to display the submitted values(Before Inserting to database),in the same page or in a different page.
Possibly thru action="<?php echo $_SERVER['PHP_SELF'];?>" that loads a dialog"this info is correct" this info is not correct,go back(or edit). I think a hidden field in an intermediate confirmation page would achieve the same result,i just didnt do that before.
So user fills form,click submit to be presented with their input(it will inevitably be inserted in the db by then),but the next page(where This input is correct leads to)overide any values if they update anything.
May 28 '07 #3

ak1dnar
Expert 100+
P: 1,584
Try to do some changes for this script. the original script is here
[PHP]<?php
if($_POST['send'])
{
$UNAME = $_POST['uname'];
$flag="OK"; // This is the flag and we set it to OK
$msg=""; // Initializing the message to hold the error messages

if(strlen($UNAME) < 5)
{ // checking the length of the entered userid and it must be more than 5 character in length
$msg=$msg."<li>Please enter user id more than 5 character length</li>";
$flag="NOTOK"; //setting the flag to error flag.
}
if($flag <>"OK"){
echo $msg;
}else
{
// all entries are correct and let us proceed with the database checking etc

}
}
?>
<html>
<body>
<form action="<?php $PHP_SELF ?>" method="POST">
USER NAME : <input name="uname" type="text" value="<?=$_POST['uname']?>"/>
<input name="send" value="SEND" type="submit" />
</form>

</body>
</html>
[/PHP]
May 28 '07 #4

ak1dnar
Expert 100+
P: 1,584
More Scripts for you give it a try.
http://www.htmlcenter.com/tutorials/...s.cfm/149/PHP/
May 28 '07 #5

P: 58
Sorry,i was not clear enough.I meant to display the user submitted data after passing validation just so they can see ALL their entered info for a last chance
May 28 '07 #6

ak1dnar
Expert 100+
P: 1,584
Sorry,i was not clear enough.I meant to display the user submitted data after passing validation just so they can see ALL their entered info for a last chance

See this line under your Original post
Can anyone share me some piece of code that displays user submitted data for another chance to verify and correct it before finally inserting it into the database?
How do you want to verify the coding.if you application is not going to verify the user inputs who is going to do it.

Any way if you want just display user entered values, try like this.

[PHP]<?php
if($_POST['send'])
{
$form = '
<form action="'.$PHP_SELF.'" method="POST">
<input name="uname" type="hidden" value="'.$_POST['uname'].'">
<input name="continue" value="continue" type="submit" />
</from><br>';
echo '<b>Inserted Values</b><br>';
echo '<li>'.$_POST['uname'].'</li>';
echo $form;
}
if($_POST['send']){
echo 'Do the stuffs for insert to MySQL';
}
?>
<html>
<body>
<form action="<?php $PHP_SELF ?>" method="POST">
USER NAME : <input name="uname" type="text" value="<?=$_POST['uname']?>"/>
<input name="send" value="SEND" type="submit" />
</form>

</body>
</html>[/PHP]
May 28 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.