PDA

View Full Version : Resolved Registration problem



greens85
11-03-2009, 01:16 PM
Hi,

I'm having problems with the process end of a registration script... I have done this many times & really don't understand why it's returning a blank screen and not adding a record to the database. The process code is:


<?php
include ("dbconnection.php");
$uname = mysql_real_escape_string($_POST['uname']);
$upass = md5($_POST['upass']);

if(isset($submit2))
{

$checkuser = mysql_query("SELECT * FROM jobseekers WHERE uname = \"$uname\"");
$username_exist = mysql_num_rows($checkuser);

if($username_exist > 0)
{
$error = 'This email address is currently in use. Please choose another email address';
echo ("Sorry this email address is already in our database, please use your browsers back button.");
exit();
}
else
{

$EXday = date('d', mktime(0,0,0,0, date(d) + 0, 0));
$EXmonth = date('m', mktime(0,0,0, date(m), date(d) + 0, 0));
$EXyear = date('Y', mktime(0,0,0,date(m) ,date(d) + 0, date(Y)));

$q1 = "insert into jobseekers set
regdate = \"$EXmonth/$EXday/$EXyear\",
uname = \"$uname\",
upass = \"$upass\",
title = \"$mtitle\",
lname = \"$lname\",
fname = \"$fname\",
address = \"$address\",
zip = \"$zip\",
country = \"$country\",
categories = \"$categories\",
experience = \"$experience\",
phone = \"$phone\"";

$r1 = mysql_query($q1) or die('error');

$q2 = "select * from jobseekers where uname = \"$uname\" ";
$r2 = mysql_query($q2) or die(mysql_error(Error5));
$a2 = mysql_fetch_array($r2);

$q4 = "insert into resumes set
jobseekerid = \"$a2[jobseekerid]\"";

$r4 = mysql_query($q4) or die('error');

echo "Registration success";
}
}
?>

I have checked the credentials in the dbconnection.php file and they are 100% correct. Can anyone see what I may be overlooking? :confused:

Many thanks,

Greens85

Phil Jackson
11-03-2009, 01:33 PM
$q1 = "INSERT INTO `jobseekers` (regdate, uname, upass, title, lname, fname, address, zip, country, categories, experience, phone) VALUES ('$EXmonth/$EXday/$EXyear', '$uname', '$upass', '$mtitle', '$lname', '$fname', '$address', '$zip', '$country', '$categories', '$experience', '$phone')";




$r1 = mysql_query($q1) or die('error' . mysql_error());

greens85
11-03-2009, 01:58 PM
$q1 = "INSERT INTO `jobseekers` (regdate, uname, upass, title, lname, fname, address, zip, country, categories, experience, phone) VALUES ('$EXmonth/$EXday/$EXyear', '$uname', '$upass', '$mtitle', '$lname', '$fname', '$address', '$zip', '$country', '$categories', '$experience', '$phone')";




$r1 = mysql_query($q1) or die('error' . mysql_error());

Hi Phil,

I've made the amends as you mentioned but the problem is still the same... a white screen is returned & no records are added to the database!

CFMaBiSmAd
11-03-2009, 02:18 PM
The posted code is dependent on $submit2 being set to do anything. Where in that code are you setting $submit2 to a value?

Phil Jackson
11-03-2009, 02:21 PM
$q4 = "INSERT INTO `resumes` (jobseekerid) VALUES ('$a2[jobseekerid]')";

greens85
11-03-2009, 02:21 PM
The posted code is dependent on $submit2 being set to do anything. Where in that code are you setting $submit2 to a value?

submit2 is the name of the button used to submit the form... I was assuming that particular line would just check to make sure submit2 had been hit... or do I actually need to post the value like:


$submit2 = $_POST['submit2'];

?

Phil Jackson
11-03-2009, 02:22 PM
The posted code is dependent on $submit2 being set to do anything. Where in that code are you setting $submit2 to a value?

also i can not see this error in your code

no records are added to the database

greens85
11-03-2009, 02:27 PM
Thanks for the reply guys.... CFM appears to have been correct. It was because I wasnt actually posting the value of the submit button. Adding the line has now got the script to work!

Many thanks for your replies!

Much appreciated