hi,
I am new to php. I have problem with the following code :
this is not generating any error but not selecting the username.
It is not giving me error when the same username already exists in the database.
The php code :
<?php
include 'common.php';
include 'db.php';
if(!isset($_POST['register']))
{
header("Location=register.php");
}
else
{
dbconnect('rishaorg_members');
}
if($_POST['newid']=='' or $_POST['firstname']=='' or $_POST['lastname']=='' or $_POST['address']=='' or $_POST['city']=='' or $_POST['state']=='' or $_POST['country']=='' or $_POST['birthcity']=='' or $_POST['birthstate']=='')
{
error('One more required fields were left blank. \\n Please fill them in and try again.');
}
if ($_POST['newemail']=='')
{
header("Location: email_error.html");
exit;
}
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $_POST['newemail']))
{
header("Location: email_error.html");
exit;
}
$sql = "SELECT COUNT (*) FROM user WHERE userid = '$_POST[newid]'";
$result = mysql_query($sql);
if(@mysql_result($result,0,0)>0)
{ error('A user alreday exists with your chosen Username. \\n Please try another Username');
}
$newpass=substr(md5(time()),0,6);
$query = "INSERT INTO user (userid, password, firstname, lastname, gender, address, city, state, country, email, phone, birthdate, birthmonth, birthyear, hour, minute, seconds, birthplace, birthplace1, agee) VALUES ('$_POST[newid]', PASSWORD('$newpass'), '$_POST[firstname]', '$_POST[lastname]', '$_POST[gender]', '$_POST[address]', '$_POST[city]', '$_POST[state]', '$_POST[country]', '$_POST[newemail]', '$_POST[phone]', '$_POST[birthdate]', '$_POST[birthmonth]', '$_POST[birthyear]', '$_POST[birthhour]', '$_POST[birthminute]', '$_POST[birthsecond]', '$_POST[birthcity]', '$_POST[birthstate]', '$_POST[agree]')";
mysql_query($query);
$message = " Congratulations !
Your personal account for the Rishi Jyotish Sanstha has been ceated !
We value your association with us.
To log in , proceed to the following address :
http://www.rishijyotishsanstha.org/index.php
Your personal login ID and password as follows :
userid : $_POST[newid]
password : $newpass
You can change your password at any time after you have logged in.
If you have any probleems feel free to contact us at :
http://www.rishijyotishsanstha.org/contactus.html
- Member's Administrator
|| Rishi Jyotish Sanstha || ";
mail($_POST['newemail'],"Member's Password for Rishi Jyotish Sanstha",$message,"From:Member Admin <members@rishijyotishsanstha.org>");
header("Location:http://www.rishijyotishsanstha.org/successfullregistration.php")
?>