Jump to content

PHP Registeration Script Error


freezicx

Recommended Posts

Hello, I'm new here but mainly registered because of my PHP registration script I written isn't working...

I'm new to PHP by the way. When I press submit on the form, it just goes back to the form again...  :confused:

 

Below is my script.

 

 

 

<?php

 

/* PHP Registeration Script, Allowing new Accounts to be Registered

*  Written By: freezicx

*  Year Written: 2011

*  Last PHP Update: 2011

*/

 

include("config.php");

 

$username = strip_tags($_POST['username']);

$password = md5(strip_tags($_POST['password']));

$vpassword = md5(strip_tags($_POST['vpassword']));

$email = strip_tags($_POST['email']);

$user_ip = $_SERVER['REMOTE_ADDR'];

$reg_date = date("d-m-Y");

 

if(isset($_POST['register']))

{

{

if (!$username || !$password || !$email || !$vpassword)

{

echo "You must fill out all fields.";

} else {       

}

$dupe1 = mysql_num_rows(mysql_query("select * from users where user='$username'"));

if ($dupe1 > 0)

{

echo "Sorry, that Username is already in use.";

} else {       

}

$dupe2 = mysql_num_rows(mysql_query("select * from users where email='$email'"));

if ($dupe2 > 0)

echo "Sorry, that Email is in use.";

} else {

}

if ($password != $vpassword)

echo "Your Passwords do not match.";

} else {     

}

mysql_query("insert into users (username, email, password, user_ip, reg_date)

values('$username','$email','$password','$user_ip','$reg_date')")or die("Error adding account information into database.");

echo 'You are registered successfully, you may now <a href="index2.php">login to your account</a>.';

}}

 

?>

<html>

<head>

<title>LevelZ - Register an Account</title>

</head>

<body>

<form action="register.php" method="post" name="register">

<table>

<tr><td>Username:</td><td><input type="text" name="username"></td></tr>

<tr><td>Email:</td><td><input type="text" name="email"></td></tr>

<tr><td>Password:</td><td><input type="password" name="password"></td></tr>

<tr><td>Verify Password:</td><td><input type="password" name="vpassword"></td></tr>

<tr><td colspan=2 align=center><input type="submit" id="register" value="Join!"></td></tr>

</table>

</form>

</body>

</html>

 

 

As I'm new to PHP, I can't see the error....

 

 

Thanks in advance any way!  :D

Link to comment
https://forums.phpfreaks.com/topic/233584-php-registeration-script-error/
Share on other sites

You're missing a certain parameter on the submit button:

 

<input type="submit" name="register" id="register" value="Join!">

 

Without it, your form processing code doesn't recognize that the form has actually been posted since it's looking for the 'register" input:

 

<?php
if (isset($_POST['register'])) 
{
    // whatever goes here
}
?>

 

Pretty sure that's it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.