Jump to content

Register page - script wont add details to mysql table


overidemehra

Recommended Posts

Hi,

 

i was jsut wondering why does not my script allow to add details when i add the username, password and email. Thought it will not allow me to take the same username or email already present in my mysql table. It even goes thorugh when i add all new details , by saying that i have registered properly and i can login. But when i check in my mysql table, no new data is added. How to fix this?

 

i am new to php... learnt over the net....

 

thanks

 

:)

 

<?php

 

$action=$_GET["action"];

 

$uname = $_POST["user"];

$pword = $_POST["pass"];

$email = $_POST["email"];

$vpass = $pword;

 

$user_name = "xxxxx";

$pass_word = "xxxxx";

$dbname="xxxx";

$table = "login";

$server = "xxxx";

 

$c=mysql_connect($server,$user_name, $pass_word, $table) OR DIE ('Unable to connect to database! Please try again later.');

$db_found=mysql_select_db($dbname);

 

 

//if registering, check fields.

if ($action == register) {

 

if (!$uname || !$pword || !$email || !$vpass) {

print "You must fill out all fields.";

 

exit;

}

$dupe1 = mysql_num_rows(mysql_query("SELECT username FROM `$table` WHERE `username` = '$uname'"));

 

if ($dupe1 > 0) {

print "Someone already has that username.";

 

exit;

}

$dupe2 = mysql_num_rows(mysql_query("SELECT email FROM `$table` WHERE `email` ='$email'"));

if ($dupe2 > 0) {

print "Someone already has that email.";

 

exit;

}

 

//check if passwords are the same

if ($pword != $vpass) {

print "The passwords do not match.";

 

exit;

}

//end

//insert

mysql_query("INSERT INTO login (username, email, pass) VALUES ('$uname','$email','$pword')");

 

print "You are now registered. Login.";

}

?>

 

<html>

<body>

 

<form method=post action=register.php?action=register  name=s>

<table>

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

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

<tr><td>Pass:</td><td><input type=password name=pass></td></tr>

<tr><td>Verify Pass:</td><td><input type=password name=vpass></td></tr>

<tr><td colspan=2 align=center><input type=submit value=Register></td></tr>

</table>

</form>

 

 

</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.