harismahesh Posted March 25, 2012 Share Posted March 25, 2012 I have a Create new account page. The form is in page named Register.php and once user submit it, it will go to Confirm.php, where it validates the field if everything is correct shows the " Account Created " Message. In Chrome. The error message is shown in Register.php and once all fields are filled then only will show confirm.php. But in Mozilla, it goes to Confirm.php and shows a blank page. My code for Register.php is : <div class="signup_form"> <form action="confirm.php" method="post" > <?php session_start(); if(isset($_SESSION['error'])) { echo '<p>'.$_SESSION['error']['username'].'</p>'; echo '<p>'.$_SESSION['error']['email'].'</p>'; echo '<p>'.$_SESSION['error']['password'].'</p>'; unset($_SESSION['error']); } ?> <p> <font size="3" face="arial" color="gray"> <label for="username"><b> UserName*</b> </label> </font> <input name="username" type="text" id="username" input style="height:33px" size = "50" size="30"/> </p> <p> <font size="3" face="arial" color="gray"> <label for="email"><b> E-mail Address*</b> </label> </font> <input name="email" type="text" id="email" input style="height:33px" size = "50" size="30"/> </p> <p> <font size="3" face="arial" color="gray"> <label for="password"><b> Password*</b> </label> </font> <input name="password" type="password" id="password" input style="height:33px" size = "50" size="30"/> </p> <p> <input name="submit" type="image" src="images/submit.gif" value="submit"/> </p> </form> </div> and for Confirm.php code is : <?php session_start(); include('configdb.php'); if(isset($_POST['submit'])) { if($_POST['username'] == '') { $_SESSION['error']['username'] = "User Name is required."; } if($_POST['email'] == '') { $_SESSION['error']['email'] = "E-mail is required."; } else { if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $_POST['email'])) { $email= $_POST['email']; $sql1 = "SELECT * FROM user WHERE email = '$email'"; $result1 = mysqli_query($mysqli,$sql1) or die(mysqli_error($mysqli)); if (mysqli_num_rows($result1) > 0) { $_SESSION['error']['email'] = "This Email is already used."; } } else { $_SESSION['error']['email'] = "Your email is not valid."; } } if($_POST['password'] == '') { $_SESSION['error']['password'] = "Password is required."; } if(isset($_SESSION['error'])) { header("Location: register.php"); exit; } else { $username = $_POST['username']; $email = $_POST['email']; $password = $_POST['password']; $sql2 = "INSERT INTO users (username, email, password) VALUES ('$username', '$email', '$password')"; $result2 = mysqli_query($mysqli,$sql2) or die(mysqli_error()); if($result2) { echo '<div>Your account is now active. You may now <a href="login.php">Log in</a></div>'; Quote Link to comment https://forums.phpfreaks.com/topic/259702-php-code-behaves-different-in-chrome-and-mozilla-browsers/ Share on other sites More sharing options...
litebearer Posted March 25, 2012 Share Posted March 25, 2012 1. is the file Confirm.php or confirm.php? 2. is the code you have shown for confirm.php, the entire content of that file? Quote Link to comment https://forums.phpfreaks.com/topic/259702-php-code-behaves-different-in-chrome-and-mozilla-browsers/#findComment-1331016 Share on other sites More sharing options...
batwimp Posted March 25, 2012 Share Posted March 25, 2012 Once it reaches the individual browser, it's only HTML, CSS, javascript, etc. that's getting parsed. This probably isn't a PHP problem, but more likely an HTML problem. Look for open tags that aren't closed, especially comment tags, in your View->Source code. Quote Link to comment https://forums.phpfreaks.com/topic/259702-php-code-behaves-different-in-chrome-and-mozilla-browsers/#findComment-1331020 Share on other sites More sharing options...
cpd Posted March 25, 2012 Share Posted March 25, 2012 Your browser won't affect your PHP. PHP is run on a server (commonly Apache) as an extension and is executed prior to any information being output to the browser. In other words your problem will be with your client side languages; not server side. The only way PHP will be affected is if the code is run on two different servers with different settings or you adjust the ini settings during run-time... I doubt it though from what you've said and posted. Quote Link to comment https://forums.phpfreaks.com/topic/259702-php-code-behaves-different-in-chrome-and-mozilla-browsers/#findComment-1331065 Share on other sites More sharing options...
PFMaBiSmAd Posted March 26, 2012 Share Posted March 26, 2012 You are using an image for your submit button. Browsers that follow the w3.org specification (apparently - Chrome, IE, Opera) submit the coordinates where the image was clicked. Other browsers that do their own thing outside of the w3.org specification submit the value = attribute. You can either test for the x or y coordinate, which works in all browsers (see this link - http://us2.php.net/manual/en/faq.html.php#faq.html.form-image ) or you can add a hidden field to your form that submits a specific name/value pair that you can test in your form processing code. Quote Link to comment https://forums.phpfreaks.com/topic/259702-php-code-behaves-different-in-chrome-and-mozilla-browsers/#findComment-1331078 Share on other sites More sharing options...
scootstah Posted March 26, 2012 Share Posted March 26, 2012 You can either test for the x or y coordinate, which works in all browsers (see this link - http://us2.php.net/manual/en/faq.html.php#faq.html.form-image ) or you can add a hidden field to your form that submits a specific name/value pair that you can test in your form processing code. Additionally, you can just check if $_POST is not empty and assume the request came from your form. You should be double-checking that relevant or necessary data exists and is in the format you expect anyway. Quote Link to comment https://forums.phpfreaks.com/topic/259702-php-code-behaves-different-in-chrome-and-mozilla-browsers/#findComment-1331106 Share on other sites More sharing options...
harismahesh Posted March 26, 2012 Author Share Posted March 26, 2012 You can either test for the x or y coordinate, which works in all browsers (see this link - http://us2.php.net/manual/en/faq.html.php#faq.html.form-image ) or you can add a hidden field to your form that submits a specific name/value pair that you can test in your form processing code. Additionally, you can just check if $_POST is not empty and assume the request came from your form. You should be double-checking that relevant or necessary data exists and is in the format you expect anyway. Exactly, that was the issue. Image submit button and if(isset($_POST['submit'])) wont match, so I used $_POST instead. Thank you all Quote Link to comment https://forums.phpfreaks.com/topic/259702-php-code-behaves-different-in-chrome-and-mozilla-browsers/#findComment-1331123 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.