hi guys,I'm trying to get a simple login system going,where in a user registers with his/her email id,an email is sent to that email id with a registration code.
That registration id is entered and verified.
Since i'm a newbie to the php world :ashamed:
I stored all the information from the form,that I got in a previous php page in session variables,so that they remain accessible on the other php page where i check for validation.
So basically just nothing happens here,if the condition of the IF is found to be true,there should be an insertion and redirect me to the register-success.php page.
What is going wrong here?
Any help will deeply appreciated!,thanks for your time!
CODE:
<?php
session_start();
$link= mysql_connect(
':/Applications/MAMP/tmp/mysql/mysql.sock',
'root',
'root'
) or die("Could not connect.");
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db("forum");
if(!$db) {
die("Unable to select database");
}
$regcode=$_POST['regcode'];
$_SESSION['random']=$random;
$fname=$_SESSION['fname'];
$lname=$_SESSION['lname'];
$login=$_SESSION['login'];
$password=$_SESSION['password'];
$email=$_SESSION['email'];
if($regcode == $random)
{
//Create INSERT query
$registerquery = mysql_query("INSERT INTO members (firstname,lastname,username,password,email) VALUES('".$fname."', '".$lname."', '".$login."','".$password."','".$email."')");
//Check whether the query was successful or not
if($registerquery) {
header("location: register-success.php");
exit();
}else {
die("Query failed");
}
}
?>
That registration id is entered and verified.
Since i'm a newbie to the php world :ashamed:
I stored all the information from the form,that I got in a previous php page in session variables,so that they remain accessible on the other php page where i check for validation.
So basically just nothing happens here,if the condition of the IF is found to be true,there should be an insertion and redirect me to the register-success.php page.
What is going wrong here?
Any help will deeply appreciated!,thanks for your time!

CODE:
<?php
session_start();
$link= mysql_connect(
':/Applications/MAMP/tmp/mysql/mysql.sock',
'root',
'root'
) or die("Could not connect.");
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db("forum");
if(!$db) {
die("Unable to select database");
}
$regcode=$_POST['regcode'];
$_SESSION['random']=$random;
$fname=$_SESSION['fname'];
$lname=$_SESSION['lname'];
$login=$_SESSION['login'];
$password=$_SESSION['password'];
$email=$_SESSION['email'];
if($regcode == $random)
{
//Create INSERT query
$registerquery = mysql_query("INSERT INTO members (firstname,lastname,username,password,email) VALUES('".$fname."', '".$lname."', '".$login."','".$password."','".$email."')");
//Check whether the query was successful or not
if($registerquery) {
header("location: register-success.php");
exit();
}else {
die("Query failed");
}
}
?>