Hi all from phphelp.com
I really need some help in here
I am setting up a registering php page wif the codes below
[php]
<?php //check form is submit if(isset ($_POST['submitted'])){ require_once ('mysql_connect.php'); //conect to db // create escape funcion function escape_data ($data) { global $dbc; //nid connect if (ini_get('magic_quotes_gpc')){ $data=stripslashes($data); } return mysql_real_escape_string(trim($data),$dbc); }// end function $errors=array(); //ini error // check email if (empty($_POST['email'])){ $error[] ='you forgt ur email'; }else { $e = escape_data($_POST[['email']); } if (empty($_POST['Fname'])){ $error[] ='you forgt ur first name'; }else { $fn= escape_data($_POST[['Fname']); } if (!empty($_POST['Lname'])){ $error[] ='you forgt ur last name'; }else { $ln = escape_data($_POST[['Lname']); } // check pass and compass if (!empty($_POST['password1'])){ if ($_POST['password1'] != $_POST['password2']){ $error[] ='Your pass dont match'; }else { $p = escape_data($_POST[['password1']); } }else { $error[] ='Your have forgt your password'; } if (empty($errors)){ // all ok //check pervious regi $query = "SELECT email FROM testdb WHERE email='$e'"; $result = mysql_query($query); if (mysql_num_rows($result) == 0){ // make the query $query="INSERT INTO testdb (email,first_name,last_name,password,registration_date) VALUES ('$e','$fn','$ln',SHA('$p'),NOW())"; $result=mysql_query($query); //run the query if ($result){ //if ran ok //print mssg echo ' THANK you ,Your are now registed'; exit(); }else{ //no run ok echo 'u are nt regi due to sys error'; //echo .mysql_error(). 'QUERY:' .$query.'
'; exit(); } }else{ //alredy regi echo' the email had already been regi'; } }else{ // report error echo'
ERROR!!!!!!
the following error(S) occured:
';
foreach ($errors as $msg) { //print each error
echo" - $msg
n";
}
echo'please try again';
} // end of if (
mysql_close(); // close DB
}
?>
REGISTER
E-mail:
First name::
Last name:
Password:
Comfirm Password:
[/php]
But i kept getting a blank page when i wanted to view it through http://localhost/
can anyone help me solve this problem ?
Details
-These codes are taken from Larry ULLMAN PHP and MYSQL
-I am using a IIS 5.1 for my PHP
-My sql 4.1
-Database is call “testdb”
-I have a page to store my SQL connection call “mysql_connect.php”
[php]
<?php //Files contain My SQL connection //database information DEFINE ('DB_USER','username"'); DEFINE ('DB_PASSWORD','databasepass'); DEFINE ('DB_HOST','localhost'); DEFINE ('DB_NAME','testdb'); //conecting to MYSQL $dbc=@mysql_connect(DB_USER,DB_PASSWORD,DB_HOST) OR die ('could Not connect to MySQL:'.mysql_error()); //select database $dbc=@mysql_connect(DB_NAME) OR die ('could Not connect to MySQL:'.mysql_error()); //create functionfor escaping data function escape_data($data){ //address magic quotes if (ini_get('magic_quotes_gpc')){ $data=stripslashes($data); } // check for my sql_real_escape_strings() support if (function_exists('mysql_real_escape_strings')) { global $dbc; //nid the connection $data=my sql_real_escape_strings(trim($data),$dbc); }else{ $data=my sql_real_escape_strings(trim($data)); } //return escape data return $data } //end of function ?>[/php]
Thank you all very much
lyjim
Mod Edit: Changed [code] tags to [php] tags.