Jump to content

[SOLVED] session causing my field to clear! need help!


theBrent

Recommended Posts

elo! i'm new here and i need help.

 

i have a registration form that receives user's input like firstname,lastname..etc. and of course a validation.

the problem is when a user mistakenly inputs a wrong validation and tries to submit it the error message and the fields are cleared, and i think it's wrong it should still display the user's input.

here is my code:

 

<? 
/* Include Files *********************/
require_once 'library/config.php';
//include"login.php";
/*************************************/
require_once 'include/header.php';

$errorMessage = '';
$secret = md5(uniqid(mt_rand(), true));
$_SESSION['secret'] = $secret;
$message =  (isset($_GET['error']) && $_GET['error'] != '') ? $_GET['error'] : '';
?>
<style type="text/css">

#hintbox{ /*CSS for pop up hint box */
position:absolute;
top: 0;
background-color: lightyellow;
width: 150px; /*Default width of hint.*/ 
padding: 3px;
border:1px solid black;
font:normal 11px Verdana;
line-height:18px;
z-index:100;
border-right: 3px solid black;
border-bottom: 3px solid black;
visibility: hidden;
}

.hintanchor{ /*CSS for link that shows hint onmouseover*/
font-weight: bold;
color: navy;
margin: 3px 8px;
}

</style>
<input type="hidden" name="secret" value="<?php echo $secret; ?>" />
<table width="795" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
<td>
	<?php require_once 'include/top.php';?>
</td>
</tr>
<tr>
<td align="center" class="mainmenu">
	<?php require_once 'include/mainmenu.php';?>
</td>
</tr>
</table>
<form action="registrationcomplete1.php" method="post" name="frmAddUser" id="frmAddUser" onsubmit='return formValidator()' >
<table width="795" border="0" cellpadding="5" cellspacing="0" align="center" style="color:purple;font-family:arial;font-size:12px;font-weight:bold">
<tr>
<td align="left" colspan="2" style="color:red"><?php echo $message; ?></td>
</tr>
<tr>
<td colspan="2" align="center" style="font-size:12px;font-weight:bold">Notice: except for the secondary address, all fields are required to be filled up. Before clicking register you must make sure that you have checked the checkbox. thank you</td>
</tr>
<tr>
<td colspan="2" align="center" style="font-size:20px;font-weight:bold">User Account Registration</td>
</tr>
<tr>
<td valign="top" rowspan="2">
<table border="0" cellpadding="3" cellspacing="0" align="center" style="color:purple;font-family:arial;font-size:12px;font-weight:bold">
<tr>
	<td colspan="2" align="center"><h3>Personal Information</h3></td>

</tr>
<tr>
	<td>First Name:</td>
	<td><input type="text" id='firstname' name="FirstName"/></td>
</tr>
<tr>
	<td>Last Name:</td>
	<td><input type="text" id='lastname' name="LastName"/></td>
</tr>
         <tr>
<td colspan="2" align="center">
<input type="checkbox" id='terms' name="terms"/>I Agree to the terms and conditions of IECC online<br />
	<input name="btnAddUser" type="submit" value="Register" onClick="return checkPassword();" />

	<input type=button value="Cancel" onClick="self.location='index.php'">

</td>
</tr>
</table>
</form>
</body>

</html>

 

and here is the succes page:

<?php

if (!isset($_POST['secret']))
     
if (($_SESSION['secret'] != $_POST['secret']) || (!isset($_SESSION['secret'])))
{
     //Call error handling function with $problem = 2 (minor security breach)
    
}
else
{
    //unset() session variable
    //unset($_SESSION['secret']);
}



require_once 'processreg.php';
?>
<body>
<table width="795" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
<td><img src="header.jpg" width="400" height="75"/></td>
<td><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="395" height="75" id="header" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="header.swf" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#3a2a67" /><embed src="header.swf" menu="false" quality="high" bgcolor="#3a2a67" width="395" height="75" name="header" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</td>
</tr>

<tr>
<td colspan="2" align="center">
	<h4 align="center">Thank you for registering at IECComputers online. You may now use your IECC account for online orders</h4><br />
						<a href="index.php">Click here to Log-in</a>
</td>
</tr>
</table>

</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.