Hello everyone,
I have a php script. Here it is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="
www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
error_reporting(0);
//Database Information
$dbhost = "localhost";
$dbname = "badbook";
$dbuser = "root";
$dbpass = "";
//Connect to database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$batch = $_POST['batch'];
$city = $_POST['city'];
$org = $_POST['org'];
$username = $_POST['username'];
$password = md5($_POST['password']);
// lets check to see if the username already exists
$checkuser = mysql_query("SELECT username FROM badbook WHERE username='$username'"

;
$username_exist = mysql_num_rows($checkuser);
if($username_exist > 0){
echo "I'm sorry but the username you specified has already been taken. Please pick another one.";
unset($username);
include 'registration.html';
exit();
}
// lf no errors present with the username
// use a query to insert the data into the database.
$query = "INSERT INTO badbook (name, email, phone, batch, city, org, username, password)
VALUES('$name', '$email', '$phone', '$batch', '$city', '$org', '$username', '$password')";
mysql_query($query) or die(mysql_error());
mysql_close();
echo "You have successfully Registered";
?>
</body>
</html>
The problem is, when I press the submit button in the other html page, this php page doesn't load; instead, it shows an error message. I get this message when I don't have internet connection, however, it is showing now with a local server running. The data entered gets in the mysql database, but the page returns this.
The reason why I'm using
error_reporting(0); is because otherwise, when i reload the page with the warning it shows :
Notice: Undefined Index: "variablename" in ../../..php in line 22Please help me with this.
Thanks
THE SCREEN WRITINGS:
Connection closed by the remote serverYou tried to access the address
localhost/www.badbook.com/registration.php, which is currently unavailable. Please make sure that the Web address (URL) is correctly spelled and punctuated, then try reloading the page.
Make sure your Internet connection is active and check whether other applications that rely on the same connection are working.