Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

signup/ login page keeps refreshing . . .?

Status
Not open for further replies.

skootz

Technical User
Jan 22, 2003
11
0
0
GB
I am running the following signup script for users to be able to log in:

<?php // signup.php

include(&quot;common.php&quot;);
include(&quot;db.php&quot;);

if(!isset($submitok)):


// Display the user signup form
?>

<html>
<head><title>New User Registration</title></head>
<body>

<h3>New User Registration Form</h3>
<p><font color=orangered size=+1><TT><B>*</B></TT></font>
indicates a required field</p>
<form method=post action=&quot;<?=$PHP_SELF?>&quot;>
<table border=0 cellpadding=0 cellspacing=5>
<tr>
<td align=right>
<p>User ID</p>
</td>
<td>
<input name=newid type=text maxlength=100 size=25>
<font color=orangered size=+1><TT><B>*</B></TT></font>
</td>
</tr>
<tr>
<td align=right>
<p>Full Name</p>
</td>
<td>
<input name=newname type=text maxlength=100 size=25>
<font color=orangered size=+1><TT><B>*</B></TT></font>
</td>
</tr>
<tr>
<td align=right>
<p>E-Mail Address</p>
</td>
<td>
<input name=newemail type=text maxlength=100 size=25>
<font color=orangered size=+1><TT><B>*</B></TT></font>
</td>
</tr>
<tr valign=top>
<td align=right>
<p>Other Notes</p>
</td>
<td>
<textarea wrap name=newnotes rows=5 cols=30></textarea>
</td>
</tr>
<tr>

<td align=right colspan=2>
<input type=reset value=&quot;Reset Form&quot;>
<input type=submit name=&quot;submitok&quot; value=&quot;Submit&quot;>
</td>
</tr>
</table>
</form>

</body>
</html>

<?php
else:
// Process signup submission
dbConnect('');

if ($newid==&quot;&quot; or $newname==&quot;&quot; or $newemail==&quot;&quot;) {
error(&quot;One or more required fields were left blank.\\n&quot;.
&quot;Please fill them in and try again.&quot;);
}

// Check for existing user with the new id
$sql = &quot;SELECT COUNT(*) FROM user WHERE userid = '$newid'&quot;;
$result = mysql_query($sql);
if (!$result) {
error(&quot;A database error occurred in processing your &quot;.
&quot;submission.\\nIf this error persists, please &quot;.
&quot;contact me@keyitskills.co.uk&quot;);
}
if (mysql_result($result,0,0)>0) {
error(&quot;A user already exists with your chosen userid.\\n&quot;.
&quot;Please try another.&quot;);
}

$newpass = substr(md5(time()),0,6);

$sql = &quot;INSERT INTO user SET
userid = '$newid',
password = PASSWORD('$newpass'),
fullname = '$newname',
email = '$newemail',
notes = '$newnotes'&quot;;
if (!mysql_query($sql))
error(&quot;A database error occurred in processing your &quot;.
&quot;submission.\\nIf this error persists, please &quot;.
&quot;contact me@keyitskills.co.uk&quot;);

// Email the new password to the person.
$message = &quot;G'Day!

Your personal account for the Project Web Site
has been created! To log in, proceed to the
following address:


Your personal login ID and password are as
follows:

userid: $newid
password: $newpass

You aren't stuck with this password! Your can
change it at any time after you have logged in.

If you have any problems, feel free to contact me at
<me@keyitskills.co.uk>.

Project Webmaster
&quot;;

mail($newemail,&quot;Your Password for the Project Website&quot;,
$message, &quot;From: me <me@keyitskills.co.uk>&quot;);

?>
<html>
<head><title> Registration Complete </title></head>
<body>
<p><strong>User registration successful!</strong></p>
<p>Your userid and password have been emailed to
<strong><?=$newemail?></strong>, the email address
you just provided in your registration form. To log in,
click <a href=&quot;signup.php&quot;>here</a> to return to the login
page, and enter your new personal userid and password.</p>
</body>
</html>
<?php
endif;
?>

However, When I bring up the page and enter data the form just refreshes and enters no data into the database.
I have tried using the $_POST array but this will not even display the form - it just echos one of the custom error messages and keeps looping.

Any suggestions on where I am going wrong would be much appreciated. Thankyou in advance for your help . . .

Skootz ;o)
 
You don't seem to have anything to decide if the variables are set....you use !isset at the top of the page, but as far as I can see, then entire part of your script runs as 1, which is probably why its not entering the data into the database, cos it doesn't knowit needs to :p

Cheers

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top