Jump to content

ThisisForReal

Members
  • Posts

    34
  • Joined

  • Last visited

Everything posted by ThisisForReal

  1. So now I've been able to isolate the problem down to just a tiny bit of code. Any smart php vets know why this works in chrome and safari and firefox but not in IE? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link href="layout_01.css" rel="stylesheet" type="text/css" /> </head> <body> <?php if (isset($_POST['submit'])) { $email = $_POST['email']; $first = $_POST['firstName']; $last = $_POST['lastName']; $password1 = $_POST['password1']; $password2 = $_POST['password2']; echo $email; echo $first; echo $last; echo $password1; echo $password2; } ?> <p>You will need to enter a valid email address. This will be your username.</p> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <fieldset> <legend>It's that easy!</legend> <table border="0"> <tr><td><label for="email">Email:</label></td> <td><input type="text" id="email" name="email" value="<?php echo $email?>"/></td></tr> <tr><td><label for="firstName">First Name:</label></td> <td><input type="text" id="firstName" name="firstName" value="<?php echo $first?>"/></td></tr> <tr><td><label for="lastName">Last Name:</label></td> <td><input type="text" id="lastName" name="lastName" value="<?php echo $last?>"/></td></tr> <tr><td><label for="password1">Password:</label></td> <td><input type="password" id="password1" name="password1" value="<?php echo $password1?>"/></td></tr> <tr><td><label for="password2">Password (retype):</label></td> <td><input type="password" id="password2" name="password2" value="<?php echo $password2?>"/></td></tr></table> </fieldset><input type="image" width="157" height="60" border="0" value="Sign Up" name="submit" src="images/signup_submit.gif"/> </form> </body> </html>
  2. Aha! I just took this piece of code from my registration page: if (isset($_POST['submit'])) and added it to the 2nd page. I just broke the second page in IE, but it's not broken in firefox. There's the problem. The $10 is off. But the thread is still open. Why is IE not liking that?
  3. Yes, that's the problem. Only in IE is there a problem (and 8 is all I have at my disposal to try). I did just try action="" and that didn't fix the IE issue. I did confirm that when the code is action="" it still works in FF. And, even though it is only in IE, when I did that second page, my 2nd set of code in the parent post, it worked for IE. That's why I'm so baffled.
  4. I was on earlier today with a topic that wound up in the HTML help section. After further debugging and testing I have realized that the error lay somewhere else and is a PHP problem. And now I'm stuck. If someone solves this, they can PM their email address and I'll send them $10 via paypal. The short: I created a site registration page. I did not like the old boring gray "submit" form box, so I replaced it with a image file. Before I did this, my registration work for safari, firefox, chrome and IE8. After switching to a custom picture file for the form submission button, it ceased to work in IE8. When one presses the button, the variables are not set and the form is wiped clean. Here's the full 81 line registration php file. First a quick guide: losidebar.php contains a side column stuff (<div id=sidecolumn>...</div>). connect4.php contains the necessary information to connect to mysql. header.php and footer.php are the first and last pieces of my html page when finished. <?php // Insert the page name $page_title = 'Registration'; require_once('header.php'); require_once('losidebar.php'); require_once('connect4.php'); // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if (isset($_POST['submit'])) { // Grab the profile data from the POST $email = mysqli_real_escape_string($dbc, trim($_POST['email'])); $firstName = mysqli_real_escape_string($dbc, trim($_POST['firstName'])); $lastName = mysqli_real_escape_string($dbc, trim($_POST['lastName'])); $password1 = mysqli_real_escape_string($dbc, trim($_POST['password1'])); $password2 = mysqli_real_escape_string($dbc, trim($_POST['password2'])); if (!empty($email) && !empty($firstName) && !empty($lastName) && !empty($password1) && !empty($password2) && ($password1 == $password2)) { //Check to see if the email address is valid and not phony if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo '<div id="mainContent">'; echo "Email is not valid. <br />"; echo "<a href=\"signup.php\">Try Again</a>. <br /></div>"; require_once('footer.php'); exit; } else { // Person has submitted data in all three fields. Passwords match. No phony email. // Call Stored Procedure spRegister // If email is unique, returns the member's id // If email is not unique, nothing is returned $encrypt = sha1($password1); $query = "CALL mealshare.spRegister('$email','$encrypt', '$firstName', '$lastName')"; $data = mysqli_query($dbc,$query) or die('Error connecting to the database'); $numrows = mysqli_num_rows($data); if ($numrows == 0) { // An account already exists for this email address, so display an error message echo '<div id="mainContent">'; echo '<p>The email address' . " " . "$email" . " " . 'has already been registered with our site.<br />'; echo '<p>If that was you, <a href="index.php">login</a> with it now.</p></div>'; require_once('footer.php'); exit; } $row = mysqli_fetch_array($data); $memberid = $row['memberID']; mysqli_close($dbc); // Redirect to a success page $home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . 'success.php'; header('Location: ' . $home_url); exit(); } } else { //Data does not match. Either password 1&2 not the same or a required field(s) is blank. echo '<p>Seems you have made a mistake. Please try again. Don\'t forget to fill in all the forms.</p>'; } } mysqli_close($dbc); ?> <div id="mainContent"> <p>You will need to enter a valid email address. This will be your username.</p> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <fieldset> <legend>It's that easy!</legend> <table border="0"> <tr><td><label for="email">Email:</label></td> <td><input type="text" id="email" name="email" value="<?php echo $email; ?>" /></td></tr> <tr><td><label for="firstName">First Name:</label></td> <td><input type="text" id="firstName" name="firstName" value="<?php echo $firstName; ?>" /></td></tr> <tr><td><label for="lastName">Last Name:</label></td> <td><input type="text" id="lastName" name="lastName" value="<?php echo $lastName; ?>" /></td></tr> <tr><td><label for="password1">Password:</label></td> <td><input type="password" id="password1" name="password1" /></td></tr> <tr><td><label for="password2">Password (retype):</label></td> <td><input type="password" id="password2" name="password2" /></td></tr></table> </fieldset><input type="image" width="157" height="60" border="0" value="Sign Up" name="submit" src="images/signup_submit.gif"/></form> <!-- end #mainContent --></div> <!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" /> <?php require_once('footer.php'); ?> </body> </html> What I've done thus far: I created a blank php file and copied just the form into this new file. I used the same image file on the same folder on the server (and, likewise, held every other variable constant I could think of). On this page, the special submit button works! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link href="layout_01.css" rel="stylesheet" type="text/css" /> </head> <body> <?php $email = $_POST['email']; $first = $_POST['firstName']; $last = $_POST['lastName']; $password1 = $_POST['password1']; $password2 = $_POST['password2']; echo $email; echo $first; echo $last; echo $password1; echo $password2; ?> <p>You will need to enter a valid email address. This will be your username.</p> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <fieldset> <legend>It's that easy!</legend> <table border="0"> <tr><td><label for="email">Email:</label></td> <td><input type="text" id="email" name="email" value="<?php echo $email?>"/></td></tr> <tr><td><label for="firstName">First Name:</label></td> <td><input type="text" id="firstName" name="firstName" value="<?php echo $first?>"/></td></tr> <tr><td><label for="lastName">Last Name:</label></td> <td><input type="text" id="lastName" name="lastName" value="<?php echo $last?>"/></td></tr> <tr><td><label for="password1">Password:</label></td> <td><input type="password" id="password1" name="password1" value="<?php echo $password1?>"/></td></tr> <tr><td><label for="password2">Password (retype):</label></td> <td><input type="password" id="password2" name="password2" value="<?php echo $password2?>"/></td></tr></table> </fieldset><input type="image" width="157" height="60" border="0" value="Sign Up" name="submit" src="images/signup_submit.gif"/> </form> </body> </html> My $10 question is why is my code not working for IE on my registration page? What is the inconsistency between the two pages? [attachment deleted by admin]
  5. Mmmm, after many attempts at isolating variables and further diagnosis, it appears to be a PHP error somewhere else on the page. I reconstructed a blank page with just the form, had it action itself and used the image in lieu of the gray submit box and got it to catch all the data I needed. So, I bow to Gibby but therein was not the answer I was looking for... Marking as problem solved.
  6. On the first set of code - with a standard submit button, the variables are sent off, php adds the person to the mySQL database, and everyone is happy. On the second set of code - and only when using IE8, the page refreshes (note the action="<?php echo $_SERVER['PHP_SELF']; ?>") but the data is not being added to the database. The only difference between the two pages is that final bit of form code: <input type="image" value="Sign Up" name="submit" src="images/signup_submit.gif"/> Why does IE not like that code when using an image file to replace the standard submit button?
  7. I hope this is a super easy question for some of you and perhaps one might be so bold as to enlighten me. Ridicule me if you must, but I'll take that if it comes with an answer. :-) I have created some basic registration and log in pages. To spruce up the forms, I modified the form submit button to an image file, rather than the old gray box. Chrome is fine with it. Firefox has no problems. Safari gets positive reviews. Of course IE is giving me trouble. Can someone spot why that is? Here's the code where IE can pass the variables to my php script correctly: <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <fieldset> <legend>It's that easy!</legend> <table border="0"> <tr><td><label for="email">Email:</label></td> <td><input type="text" id="email" name="email" value="<?php if (!empty($email)) echo $email; ?>" /></td></tr> <tr><td><label for="firstName">First Name:</label></td> <td><input type="text" id="firstName" name="firstName" value="<?php if (!empty($firstName)) echo $firstName; ?>" /></td></tr> <tr><td><label for="lastName">Last Name:</label></td> <td><input type="text" id="lastName" name="lastName" value="<?php if (!empty($lastName)) echo $lastName; ?>" /></td></tr> <tr><td><label for="password1">Password:</label></td> <td><input type="password" id="password1" name="password1" /></td></tr> <tr><td><label for="password2">Password (retype):</label></td> <td><input type="password" id="password2" name="password2" /></td></tr></table> </fieldset> <input type="submit" value="Sign Up" name="submit"/> </form> All 4 browsers pass that test. However, only 3 can pass the following (to save time, just look at the last line, it the only thing that's different): <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <fieldset> <legend>It's that easy!</legend> <table border="0"> <tr><td><label for="email">Email:</label></td> <td><input type="text" id="email" name="email" value="<?php if (!empty($email)) echo $email; ?>" /></td></tr> <tr><td><label for="firstName">First Name:</label></td> <td><input type="text" id="firstName" name="firstName" value="<?php if (!empty($firstName)) echo $firstName; ?>" /></td></tr> <tr><td><label for="lastName">Last Name:</label></td> <td><input type="text" id="lastName" name="lastName" value="<?php if (!empty($lastName)) echo $lastName; ?>" /></td></tr> <tr><td><label for="password1">Password:</label></td> <td><input type="password" id="password1" name="password1" /></td></tr> <tr><td><label for="password2">Password (retype):</label></td> <td><input type="password" id="password2" name="password2" /></td></tr></table> </fieldset> <input type="image" value="Sign Up" name="submit" src="images/signup_submit.gif"/> </form> I've googled around for an answer but I kept getting solutions to vastly trickier issues. Thanks in advance!
  8. Oh, that's hilarious. I tried to check against that issue by created a new page and running this: <?php $password1 = soccer; $encrypt = sha1($password1); $password2 = beer; $encrypt2 = sha1('$password2'); echo "$encrypt <br />"; echo "$encrypt2"; ?> The page shot out 2 hashes, and neither matched what was being put in the database on my registration page, so I had eliminated that as a cause. Now I realize I ran a faulty experiment because in the above experiment, it's password2 that has the quotes around it (thus the hash is of *$password2* rather than the value of the variable) rather than password1. Had I put the quotes around password1 in my experiment, it'd have matched my db entries and I would have solved the problem. Funny, because I'm not a total noob, but it's so easy to trip up on trial and error if you're not really careful about how you approach these things... Thanks a bunch!
  9. I recognize a lot of the OP's code from the O'Reilly HeadStart PHP MySQL book. Good stuff. I am creating a similar page. Got mine to work just fine. But now I'm trying to replace some of the querying with a stored procedure. The stored procedure is working just fine, except, I'm having trouble doing an SHA1 on the password before passing the variable along to the MySQL stored procedure to add to the DB table. I'm essentially going from Mickey's code (seen here): // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if (mysqli_connect_error()) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } if (isset($_POST['submit'])) { // Grab the profile data from the POST $firstname = mysqli_real_escape_string($dbc, trim($_POST['firstname'])); $password1 = mysqli_real_escape_string($dbc, trim($_POST['password1'])); $password2 = mysqli_real_escape_string($dbc, trim($_POST['password2'])); if (!empty($firstname) && !empty($password1) && !empty($password2) && ($password1 == $password2)) { // Make sure someone isn't already registered using this username $query = "SELECT * FROM clients WHERE firstname = '$firstname'"; $data = mysqli_query($dbc, $query) or die('error connecting to db'); if (mysqli_num_rows($data) == 0) { // The username is unique, so insert the data into the database $query = "INSERT INTO clients (firstname, password1) VALUES ('$firstname', SHA1('$password1'))"; mysqli_query($dbc, $query) or die('wtf?'); And now I'm trying to simplify it as such: <?php // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if (isset($_POST['submit'])) { // Grab the profile data from the POST $email = mysqli_real_escape_string($dbc, trim($_POST['email'])); $password1 = mysqli_real_escape_string($dbc, trim($_POST['password1'])); $password2 = mysqli_real_escape_string($dbc, trim($_POST['password2'])); if (!empty($email) && !empty($password1) && !empty($password2) && ($password1 == $password2)) { // Person has submitted data in all three fields and passwords match. $encrypt = sha1('$password1'); $query = "CALL mealshare.spRegister('$email','$encrypt')"; $data = mysqli_query($dbc, $query); My problem is that no matter what I enter as a password on the registration page, the encrypted entry in the DB table is always the SAME 40 character hash. Anybody have any clues where my SHA is breaking down?
×
×
  • 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.