Jump to content

Recommended Posts

Basically, code works fine (somehow, I know it looks a mess :)). Anyway, a few minor problems ..

 

#1. When the form has been completed and the registration is successful, it echos this top left of the page which is fine for now, however the register form also reappears, I want to make it so that doesn't reappear, is there a way?

 

#2. It is possible for people to click refresh and duplicate an entry, also if I visit the link directly it again creates a duplicate entry in the Users table. Not so minor this one, but i'm sure theres something simple to fix it. :)

 

If there is anything else you spot which needs to be adjusted, please do tell :)

 

<html>
<body>

<?php

include 'config.php';
include 'opendb.php';

if ($_POST['Submit']) {

$uname = $_POST["uname"];
$pword = $_POST["pword"];
$pword1 = $_POST["pword1"];
$jmail = $_POST["email"];
$age = $_POST["age"];
$chkname = mysql_query("SELECT * FROM Users WHERE usname='$uname'");
$salt = 's+(_a*';
$salt_pass = md5($pword.$salt);
$ip = $_SERVER['REMOTE_ADDR'];
$datum = date("d-m-y / H:i:s");

if(mysql_num_rows($chkname) > 0 ) {
echo "Username already in use";

} else {

if ($pword != $pword1) {
echo "The two passwords do not match";

} else {

if (strlen($pword) > 25 || strlen($pword) < 6 ) {
echo "Your password must be between 6 and 25 characters!";

} else {

if (strlen($uname) > 16 || strlen($uname) < 4 ) {
echo "Your username must be between 4 and 16 characters!";

} else {

$sql="INSERT INTO Users (usname, userpass, useremail, userage, JoinDate, IPAddress)
VALUES
('$uname','$salt_pass','$jmail','$age','$datum','$ip')";

if (!mysql_query($sql))
  {
  die('Error: ' . mysql_error());
  }

?>


Registation Successful!<br /><br />
You may now <a href="index.php">login!</a>

<?php

}
}
}
}
}

?>

<table width="300" border="0" align="center" cellpadding="0" cellspacing="1"
bgcolor="#CCCCCC">
<tr>
<form name="form1" Method="POST" ACTION="index2.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Register </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="uname" type="text" id="uname" maxlength="16" /></td>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="pword" type="password" id="pword" maxlength="25" /></td>
<tr>
<td>Re-enter</td>
<td>:</td>
<td><input name="pword1" type="password" id="pword1" maxlength="25" /></td>
<tr>
<td>Email</td>
<td>:</td>
<td><input name="email" type="text" id="email" maxlength="50" /></td>
<tr>
<td>Age</td>
<td>:</td>
<td><input name="age" type="text" id="age" maxlength="2" /></td>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Register"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>

<?php
include 'closedb.php';
?> 

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/172257-login-errorish/
Share on other sites

#1. When the form has been completed and the registration is successful, it echos this top left of the page which is fine for now, however the register form also reappears, I want to make it so that doesn't reappear, is there a way?

 

$showRegistrationForm = true display's it false doesn't

 

#2. It is possible for people to click refresh and duplicate an entry, also if I visit the link directly it again creates a duplicate entry in the Users table. Not so minor this one, but i'm sure theres something simple to fix it. :)

 

Take a look at http://www.phpfreaks.com/forums/index.php/topic,266890.msg1258749.html#msg1258749 What also may help is: unset($_POST) not sure though (I even have my doubts about this one as post data is send trough the request headers).

 

 

Link to comment
https://forums.phpfreaks.com/topic/172257-login-errorish/#findComment-908232
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.