Jump to content

CSS Stopping Next Page Loading


justlukeyou

Recommended Posts

I have a script which registers people to a database, however it doing something very strange.  Whenever I place it into even a single CSS div it adds the registration to the dabase but stops loading the next page (index.php)

 

I find this totally bizarre as I haven't seen anything like this behave before.  With CSS affecting how PHP works.  Especially when the CSS is not inside the <php> of <form> tags.

 

<?php

include("connect.php");

if($_POST['submit']) {
    $username = mysql_real_escape_string(trim($_POST['username']));
    $password = trim($_POST['password']);
    $password2 = trim($_POST['password2']);
    $email = mysql_real_escape_string(trim($_POST['email']));
    $error = false;
    
    if(!isset($username) || empty($username)) {
        $error = "You need to enter a username.";
    }
    $query = mysql_query("SELECT id FROM users WHERE username = '".$username."' LIMIT 1");
    if(mysql_num_rows($query) > 0 && !$error) {
        $error = "Sorry, that username is already taken!";
    }
    
    if((!isset($password) || empty($password)) && !$error) {
        $error = "You need to enter a password.";
    }
    if((!isset($password2) || empty($password2)) && !$error) {
        $error = "You need to enter your password twice.";
    }
    if($password != $password2 && !$error) {
        $error = "The passwords you entered did not match.";
    }
    
    if((!isset($email) || empty($email)) && !$error) {
        $error = "You need to enter an email.";
    }
    if(preg_match("/[a-zA-Z0-9-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email) == 0 && !$error) {
        $error = "The email you entered is not valid.";
    }
    $query = mysql_query("SELECT id FROM users WHERE email = '".$email."' LIMIT 1");
    if(mysql_num_rows($query) > 0 && !$error) {
        $error = "Sorry, that email is already in use!";
    }
    
    if(!$error) {
        $query = mysql_query("INSERT INTO users (username, password, email) VALUES ('".$username."', '".mysql_real_escape_string(md5($password))."', '".$email."')");
        if($query) {
            $message = "Hello ".$_POST['username'].",\r\n\r\nThanks for registering! We hope you enjoy your stay.\r\n\r\nThanks,\r\nJohn Doe";
            $headers = "From: ".$website['name']." <".$website['email'].">\r\n";
            mail($_POST['email'], "Welcome", $message, $headers);
            setcookie("user", mysql_insert_id(), $time);
            setcookie("pass", mysql_real_escape_string(md5($password)), $time);
            header("Location: index.php");
        } else {
            $error = "There was a problem with the registration. Please try again.";
        }
    }
}

?><html>

<head>
<title>Register</title>
</head>

<body>
<form action="" method="post">
    <?php if($error) echo "<span style=\"color:#ff0000;\">".$error."</span><br /><br />"; ?>
    <label for="username">Username: </label> <input type="text" name="username" value="<?php if($_POST['username']) echo $_POST['username']; ?>" /><br />
    <label for="password">Password: </label> <input type="password" name="password" value="<?php if($_POST['password']) echo $_POST['password']; ?>" /><br />
    <label for="password2">Retype Password: </label> <input type="password" name="password2" value="<?php if($_POST['password2']) echo $_POST['password2']; ?>" /><br />
    <label for="email">Email: </label> <input type="text" name="email" value="<?php if($_POST['email']) echo $_POST['email']; ?>" /><br /><br />
    <input type="submit" name="submit" value="Register" />
</form>
</body>

Link to comment
Share on other sites

This is the copy with css in, but I have never come across this problem before and I have the same pafe displaying another PHP script which echos infromation from a database.

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>





<link rel="stylesheet" href="http://www.domain.co.uk/test/style.css" type="text/css" />


<body>
<div class="homepageloginborder">
<?php

include("connect.php");

if($_POST['submit']) {
    $username = mysql_real_escape_string(trim($_POST['username']));
    $password = trim($_POST['password']);
    $password2 = trim($_POST['password2']);
    $email = mysql_real_escape_string(trim($_POST['email']));
    $error = false;
    
    if(!isset($username) || empty($username)) {
        $error = "You need to enter a username.";
    }
    $query = mysql_query("SELECT id FROM users WHERE username = '".$username."' LIMIT 1");
    if(mysql_num_rows($query) > 0 && !$error) {
        $error = "Sorry, that username is already taken!";
    }
    
    if((!isset($password) || empty($password)) && !$error) {
        $error = "You need to enter a password.";
    }
    if((!isset($password2) || empty($password2)) && !$error) {
        $error = "You need to enter your password twice.";
    }
    if($password != $password2 && !$error) {
        $error = "The passwords you entered did not match.";
    }
    
    if((!isset($email) || empty($email)) && !$error) {
        $error = "You need to enter an email.";
    }
    if(preg_match("/[a-zA-Z0-9-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email) == 0 && !$error) {
        $error = "The email you entered is not valid.";
    }
    $query = mysql_query("SELECT id FROM users WHERE email = '".$email."' LIMIT 1");
    if(mysql_num_rows($query) > 0 && !$error) {
        $error = "Sorry, that email is already in use!";
    }
    
    if(!$error) {
        $query = mysql_query("INSERT INTO users (username, password, email) VALUES ('".$username."', '".mysql_real_escape_string(md5($password))."', '".$email."')");
        if($query) {
            $message = "Hello ".$_POST['username'].",\r\n\r\nThanks for registering! We hope you enjoy your stay.\r\n\r\nThanks,\r\nJohn Doe";
            $headers = "From: ".$website['name']." <".$website['email'].">\r\n";
            mail($_POST['email'], "Welcome", $message, $headers);
            setcookie("user", mysql_insert_id(), $time);
            setcookie("pass", mysql_real_escape_string(md5($password)), $time);
            header("Location: index.php");
        } else {
            $error = "There was a problem with the registration. Please try again.";
        }
    }
}

?>




<form action="" method="post">
    <?php if($error) echo "<span style=\"color:#ff0000;\">".$error."</span><br /><br />"; ?>
    <label for="username">Username: </label> <input type="text" name="username" value="<?php if($_POST['username']) echo $_POST['username']; ?>" /><br />
    <label for="password">Password: </label> <input type="password" name="password" value="<?php if($_POST['password']) echo $_POST['password']; ?>" /><br />
    <label for="password2">Retype Password: </label> <input type="password" name="password2" value="<?php if($_POST['password2']) echo $_POST['password2']; ?>" /><br />
    <label for="email">Email: </label> <input type="text" name="email" value="<?php if($_POST['email']) echo $_POST['email']; ?>" /><br /><br />
    <input type="submit" name="submit" value="Register" />
</form>
</div>
</body>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.