SuperMode55
12-19-2011, 07:05 PM
Hello
I am building a registration page . If the user completes all the required field i load the info into the database but if there are missing fields I combined some javascript into php to display next to the empty field a note that it should be filled. This is my code :
<?php
if (isset($_POST['submit']))
{
$username =$_POST['username'];
$password =$_POST['password'];
$password2 =$_POST['password2'];
$firstname =$_POST['firstname'];
$lastname =$_POST['lastname'];
$email =$_POST['email'];
$address =$_POST['address'];
$city =$_POST['city'];
$state =$_POST['state'];
$zip =$_POST['zip'];
$dob =$_POST['dob'];
if (empty($username)){
?> <script language="javascript">
var user =true
</script> ;<?
}
if (empty($password)){
?> <script language="javascript">
var pass =true
</script><? ;
}
And it goes on...................
Then next to the inpput box I display a text in case the user didn't fill in the info like this and by the way the above code is in my validate.php page wich i include in the main registration page
<?php include ('includes/validate.php');?>
<form action="registration.php" method= "post" >
<fieldset>
<legend>sitename Registration</legend>
<p>
<label for"username">Username</label>
<input type "text" name=username /> <script type="text/javascript">
if (user == true)
{
document.write("Please enter a Username of your choice");
}
</script>
</p>
<p>
<label for"password">Password</label>
<input type "password" name=password /> <script type="text/javascript">
if (pass == true)
{
document.write("Please choose a Password");
}
</script>
</p>
<p>
<label for"password2">Re-type Password</label>
<input type "pass2" name=password2 /> <script type="text/javascript">
if (pass2 == true)
{
document.write("Please re-type your Password");
}
</script>
</p>
And it goes on......for the rest of the input fields.
I need some help with a solution for when the user fills in the info and pushes the "register" button the page refreshes and it whipes all the info the user already input but it does display the warnings where the user didn't input any data, so what would be the best way to go to keep the data that the user entered.Thank you.
I am building a registration page . If the user completes all the required field i load the info into the database but if there are missing fields I combined some javascript into php to display next to the empty field a note that it should be filled. This is my code :
<?php
if (isset($_POST['submit']))
{
$username =$_POST['username'];
$password =$_POST['password'];
$password2 =$_POST['password2'];
$firstname =$_POST['firstname'];
$lastname =$_POST['lastname'];
$email =$_POST['email'];
$address =$_POST['address'];
$city =$_POST['city'];
$state =$_POST['state'];
$zip =$_POST['zip'];
$dob =$_POST['dob'];
if (empty($username)){
?> <script language="javascript">
var user =true
</script> ;<?
}
if (empty($password)){
?> <script language="javascript">
var pass =true
</script><? ;
}
And it goes on...................
Then next to the inpput box I display a text in case the user didn't fill in the info like this and by the way the above code is in my validate.php page wich i include in the main registration page
<?php include ('includes/validate.php');?>
<form action="registration.php" method= "post" >
<fieldset>
<legend>sitename Registration</legend>
<p>
<label for"username">Username</label>
<input type "text" name=username /> <script type="text/javascript">
if (user == true)
{
document.write("Please enter a Username of your choice");
}
</script>
</p>
<p>
<label for"password">Password</label>
<input type "password" name=password /> <script type="text/javascript">
if (pass == true)
{
document.write("Please choose a Password");
}
</script>
</p>
<p>
<label for"password2">Re-type Password</label>
<input type "pass2" name=password2 /> <script type="text/javascript">
if (pass2 == true)
{
document.write("Please re-type your Password");
}
</script>
</p>
And it goes on......for the rest of the input fields.
I need some help with a solution for when the user fills in the info and pushes the "register" button the page refreshes and it whipes all the info the user already input but it does display the warnings where the user didn't input any data, so what would be the best way to go to keep the data that the user entered.Thank you.