rdkd1970 Posted April 30, 2011 Share Posted April 30, 2011 I have recently tried this coding to update to my database it works differently in two browsers IE and Chrome. In chrome it just goes to the next page (before it was adding data to DB) and not going to next page. Now IE just adds data to DB and does not go to next page. Can someone take a look and let me know what I have to do to fix this. thanks <?php @include('Connections/connect_to_mysql.php'); $err=''; if($_POST["submit"]){ // Validate form data if($_POST["firstname"]=='') $err.='Please enter First Name<br>'; if($_POST["email"]=='') $err.='Please enter Email<br>'; if($err==''){ // Check if there are duplicate entries in the 'contacts' table $r=mysql_query("SELECT ID FROM Members WHERE firstname='".addslashes($_POST["firstname"])."' and Email='".addslashes($_POST["email"])."'"); if(mysql_num_rows($r)){ $err.='Can not add duplicate entry<br>'; } else{ // adding new record to 'contacts' table mysql_query("INSERT INTO Members (firstname,lastname,country,Email) values ('".addslashes($_POST["firstname"])."','".addslashes($_POST["lastname"])."','".addslashes($_POST["country"])."','".addslashes($_POST["email"])."')"); // redirecting to success screen exit; } } } ?> <html> <head> <title>Add New Contact</title> </head> <body> <h2>Register with us</h2> <?php echo $err==''?'''<p style="color:red;">'.$err.'</p>') ?> <form method="post" action="form.php"> <table border="0"> <tr> <td valign="middle">First Name:</td> <td><input type="text" name="firstname" size="30" value="<?php echo htmlspecialchars($firstname) ?>"></td> </tr> <tr> <td valign="middle">Last Name:</td> <td><input type="text" name="lastname" size="30" value="<?php echo htmlspecialchars($lastname) ?>"></td> </tr> <tr> <td valign="middle">Country:</td> <td><input type="text" name="country" size="30" value="<?php echo htmlspecialchars($country) ?>"></td> </tr> <tr> <td valign="middle">Email:</td> <td><input type="text" name="email" size="30" value="<?php echo htmlspecialchars($email) ?>"></td> </tr> </table><br> <a href="http://www.ebermylove.com/login.php"><input type="submit" name="submit" value=" Submit! "></a> </form> </body> </html> login.php <?php session_id(); session_start(); ?> <!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>Welcome</title> </head> <body> <?php /* Program: New_member.php * Desc: Displays the new member welcome page. Greets * member by name and gives a choice to enter * restricted section or go back to main page. */ if (@$_SESSION['auth'] != "yes") @include('Connections/connect_to_mysql.php'); $link = mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql"); $link = mysql_select_db("$db_name") or die ("Query died:"); $query = "SELECT firstName, lastName FROM `Members` WHERE email='{$_SESSION['id']}'"; $result = @mysql_result($query,$link) or die("Could not execute query"); echo "<html> <head><title>New Member Welcome</title></head> <body> <h2 style='margin-top: .7in; text-align: center'> Welcome $firstName </h2>\n"; ?> <p>Your new Member accounts lets you enter the members only section of our web site. You'll find special discounts, a profile of matches, live advise for experts, and much more.</p> <p>Your new Member ID and password were emailed to you. Store them carefully for future use.</p> <div style="text-align: center"> <p style="margin-top: .5in; font-weight: bold"> Glad you could join us!</p> <form action="profile.php" method="post"> <input type="submit" value="Enter the Members Only Section"> </form> <form action="index.php" method="post"> <input type="submit" value="Go to eBermylove Main Page"> </form> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/235226-going-to-next-page-problems/ Share on other sites More sharing options...
wildteen88 Posted April 30, 2011 Share Posted April 30, 2011 I don't think you can make a submit button a link <a href="http://www.ebermylove.com/login.php"><input type="submit" name="submit" value=" Submit! "></a> What are you trying to do submit the form to login.php and form.php? PS when posting code wrap it within or tags Quote Link to comment https://forums.phpfreaks.com/topic/235226-going-to-next-page-problems/#findComment-1208813 Share on other sites More sharing options...
rdkd1970 Posted May 1, 2011 Author Share Posted May 1, 2011 Are you saying to set it up like... <?php <a href "login.php" > </a> ?> The the submit button info... Quote Link to comment https://forums.phpfreaks.com/topic/235226-going-to-next-page-problems/#findComment-1208838 Share on other sites More sharing options...
wildteen88 Posted May 1, 2011 Share Posted May 1, 2011 No not at all. I am saying this <a href="http://www.ebermylove.com/login.php"><input type="submit" name="submit" value=" Submit! "></a> Is invalid html syntax. What are you trying to do when the form is submitted? Quote Link to comment https://forums.phpfreaks.com/topic/235226-going-to-next-page-problems/#findComment-1208962 Share on other sites More sharing options...
rdkd1970 Posted May 1, 2011 Author Share Posted May 1, 2011 When I hit the submit button I want it to go to login.php page Quote Link to comment https://forums.phpfreaks.com/topic/235226-going-to-next-page-problems/#findComment-1209009 Share on other sites More sharing options...
wildteen88 Posted May 1, 2011 Share Posted May 1, 2011 You do not wrap an anchor tag around a submit button to send the user to login.php. Where the form submits the data to is controlled by the action attribute <form action="login.php" method="post"> Quote Link to comment https://forums.phpfreaks.com/topic/235226-going-to-next-page-problems/#findComment-1209042 Share on other sites More sharing options...
rdkd1970 Posted May 1, 2011 Author Share Posted May 1, 2011 Thanks that was easy I had the name of the form in that space where it should have been login.php to be redirected to the login page. Quote Link to comment https://forums.phpfreaks.com/topic/235226-going-to-next-page-problems/#findComment-1209155 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.