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
https://forums.phpfreaks.com/topic/230529-css-stopping-next-page-loading/
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>

Archived

This topic is now archived and is closed to further replies.

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