Jump to content

Floore

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Floore's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm not using localhost, it's an online server and I've not had this problem before.
  2. Before my script is requested? What do you mean?
  3. I have been learning PHP over the last week or so, currently trying to write a login script and I am now constantly getting a blank page showing no errors. I have no idea what is wrong but my form just will not process. I've cut bits of code out and written it different ways, but there seems to be no answer! Can anyone help? Here is my code: (I have hashed out the login info but I am 100% sure it's correct) <?php //Show me my mistakes! ini_set('display_errors', 1); error_reporting (E_ALL); //Connect to the database $host = "#"; $port = 3306; //The default port for mySQL is 3306 $username = "#"; $password = "#"; $database = "#"; mysql_connect($host, $username, $password) or Die("Couldn't Connect: " . mysql_error()); mysql_select_db($database) or Die("Couldn't connect to database: " . mysql_error()); //Confirm submission of the form (and not direct access) $user = $_POST['username']; $pass = $_POST['password']; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $email2 = $_POST['email2']; $sex = $_POST['sex']; $firstline = $_POST['firstline']; $town = $_POST['town']; $postcode = $_POST['postcode']; //Check 1/2 - Find out if the user still exists $find_user_query = mysql_query("SELECT * FROM accounts WHERE username = $user") or Die("Couldn't connect: " . mysql_error(); $find_user = mysql_num_rows($find_user_query); //If so, notify the user and ask for an alternative if ($find_user > 0) { echo "User $user already exists, please choose another username<br /><br />"; echo "<p><div style=\"width: 550px; padding: 20px; background-color: #FFAA00\"> <form class=\"createuser\" name=\"create\" action=\"createuser.php\" method=\"POST\"> <b>Personal Information:</b><br /><br /> <label for=\"username\">Username: <font color=\"red\">*</font></label> <input type=\"text\" name=\"username\" value=\"\" /><br /> <label for=\"password\">Password: <font color=\"red\">*</font></label> <input type=\"password\" name=\"password\" value=\"\" /><br /> <label for=\"firstname\">First Name: <font color=\"red\">*</font></label> <input type=\"text\" name=\"firstname\" value=\"$firstname\" /><br /> <label for=\"lastname\">Last Name: <font color=\"red\">*</font></label> <input type=\"text\" name=\"lastname\" value=\"$lastname\" /><br /> <label for=\"email\">E-mail: <font color=\"red\">*</font></label> <input type=\"text\" name=\"email\" value=\"$email\" /><br /> <label for=\"email2\">Confirm E-mail: <font color=\"red\">*</font></label> <input type=\"text\" name=\"email2\" value=\"$email2\" /><br /> <label for=\"sex\">Sex:</label> <input type=\"radio\" name=\"sex\" value=\"M\" /> Male <input type=\"radio\" name=\"sex\" value=\"F\" /> Female<br /> <label for=\"firstline\">First Line of Address: <font color=\"red\">*</font></label> <input type=\"text\" name=\"firstline\" value=\"$firstline\" /><br /> <label for=\"town\">Town: <font color=\"red\">*</font></label> <input type=\"text\" name=\"town\" value=\"$town\" /><br /> <label fpr=\"postcode\">Post Code: <font color=\"red\">*</font></label> <input type=\"text\" name=\"postcode\" value=\"$postcode\" /><br /> <label for=\"submit\"> </label><input type=\"submit\" value=\"Sign Up\" /> </form> </div>"; //Check 2/2 - If username is free, check for any blank fields } elseif (empty($user) || empty($pass) || empty($firstname) || empty($lastname) || empty($email) || empty($sex) || empty($firstline) || empty($town) || empty($postcode)) { echo "Please fill out ALL Required fields<br /><br /><br />"; echo "<div style=\"width: 550px; padding: 20px; background-color: #FFAA00\"> <form class=\"createuser\" name=\"create\" action=\"createuser.php\" method=\"POST\"> <b>Personal Information:</b><br /><br /> <label for=\"username\">Username: <font color=\"red\">*</font></label> <input type=\"text\" name=\"username\" value=\"$user\" /><br /> <label for=\"password\">Password: <font color=\"red\">*</font></label> <input type=\"password\" name=\"password\" value=\"\" /><br /> <label for=\"firstname\">First Name: <font color=\"red\">*</font></label> <input type=\"text\" name=\"firstname\" value=\"$firstname\" /><br /> <label for=\"lastname\">Last Name: <font color=\"red\">*</font></label> <input type=\"text\" name=\"lastname\" value=\"$lastname\" /><br /> <label for=\"email\">E-mail: <font color=\"red\">*</font></label> <input type=\"text\" name=\"email\" value=\"$email\" /><br /> <label for=\"email2\">Confirm E-mail: <font color=\"red\">*</font></label> <input type=\"text\" name=\"email2\" value=\"$email2\" /><br /> <label for=\"sex\">Sex:</label> <input type=\"radio\" name=\"sex\" value=\"M\" /> Male <input type=\"radio\" name=\"sex\" value=\"F\" /> Female<br /> <label for=\"firstline\">First Line of Address: <font color=\"red\">*</font></label> <input type=\"text\" name=\"firstline\" value=\"$firstline\" /><br /> <label for=\"town\">Town: <font color=\"red\">*</font></label> <input type=\"text\" name=\"town\" value=\"$town\" /><br /> <label fpr=\"postcode\">Post Code: <font color=\"red\">*</font></label> <input type=\"text\" name=\"postcode\" value=\"$postcode\" /><br /> <label for=\"submit\"> </label><input type=\"submit\" value=\"Sign Up\" /> </form> </div>"; //If everything is OK, allow the user to be created and present them with the login page } else { $query = "INSERT INTO accounts (username, password, firstname, lastname, email, sex, firstline, town, postcode) VALUES ('$user', '$pass', '$firstname', '$lastname', '$email', '$sex', '$firstline', '$town', '$postcode'"; if (@mysql_query($query)) { echo 'User created, please login below:'; echo '<form class="login" name="login" action="signin.php" method="POST">'; echo '<label for="username">Username: </label><input type="text" name="username" maxlength="12"><br /> <label for="password">Password: </label><input type="password" name="password" maxlength="12"> <input type="submit" name="submit" value="submit"> </form>'; } else { echo "Could not complete request for the following reason: " . mysql_error(); echo "<br /><br />The query being run was: " . $query; } mysql_close() } //All Done!! New User!! ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.