netpants Posted November 1, 2007 Share Posted November 1, 2007 I just want to be sure about the redirect. I have a form called insert.html and it posts to insertguts.php , the insertguts page doesnt display anything, but after it enters the information from the form i want it to redirect. I have tried before but it redirects before it enters the information into the database. How can I fix this please. // connect and select the database $conn = mysql_connect($host, $user, $password) or die(mysql_error()); $db = mysql_select_db($dbName, $conn) or die(mysql_error()); if (isset($_POST['newCity']) && trim($_POST['newCity']) != '') { // for easier variable handling... $newCity = $_POST['newCity']; $newCounty = $_POST['newCounty']; $newNumber = $_POST['newNumber']; $newStreet = $_POST['newStreet']; $newSfx = $_POST['newSfx']; $newCp = $_POST['newCp']; $newCoordinates = $_POST['newCoordinates']; $newZip = $_POST['newZip']; // insert new entry into database $sql = "insert into coords (county,city,number,street,sfx,cp,coordinates,zip) values ('$newCounty','$newCity','$newNumber','$newStreet','$newSfx','$newCp','$newCoordinates','$newZip')"; $result = mysql_query($sql, $conn) or die(mysql_error()); } // end if new entry posted // select all the entries from the table $sql = "select city from coords"; $result = mysql_query($sql, $conn) or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/75654-redirect-question/ Share on other sites More sharing options...
suttercain Posted November 1, 2007 Share Posted November 1, 2007 Hi netpants, I know some people use the header() function, but I use javascript... $conn = mysql_connect($host, $user, $password) or die(mysql_error()); $db = mysql_select_db($dbName, $conn) or die(mysql_error()); if (isset($_POST['newCity']) && trim($_POST['newCity']) != '') { // for easier variable handling... $newCity = $_POST['newCity']; $newCounty = $_POST['newCounty']; $newNumber = $_POST['newNumber']; $newStreet = $_POST['newStreet']; $newSfx = $_POST['newSfx']; $newCp = $_POST['newCp']; $newCoordinates = $_POST['newCoordinates']; $newZip = $_POST['newZip']; // insert new entry into database $sql = "insert into coords (county,city,number,street,sfx,cp,coordinates,zip) values ('$newCounty','$newCity','$newNumber','$newStreet','$newSfx','$newCp','$newCoordinates','$newZip')"; $result = mysql_query($sql, $conn) or die(mysql_error()); } // end if new entry posted if ($result) { echo "<script type=\"text/javascript\">document.location.href='http://www.urlhere.com'</script>";//Redirect } Quote Link to comment https://forums.phpfreaks.com/topic/75654-redirect-question/#findComment-382844 Share on other sites More sharing options...
GingerRobot Posted November 1, 2007 Share Posted November 1, 2007 Unless you need to do a timed redirect, you'd be better off using the header() function. What about users who have javascript disabled? Quote Link to comment https://forums.phpfreaks.com/topic/75654-redirect-question/#findComment-382850 Share on other sites More sharing options...
suttercain Posted November 1, 2007 Share Posted November 1, 2007 If the user has javascript disabled, they need to get with the times Quote Link to comment https://forums.phpfreaks.com/topic/75654-redirect-question/#findComment-382853 Share on other sites More sharing options...
netpants Posted November 1, 2007 Author Share Posted November 1, 2007 It doesnt matter about the javascript as it will be in an administration area, not user area. Thanks guys/gals Quote Link to comment https://forums.phpfreaks.com/topic/75654-redirect-question/#findComment-382857 Share on other sites More sharing options...
suttercain Posted November 1, 2007 Share Posted November 1, 2007 Did it work ok for you? Quote Link to comment https://forums.phpfreaks.com/topic/75654-redirect-question/#findComment-382860 Share on other sites More sharing options...
ToonMariner Posted November 1, 2007 Share Posted November 1, 2007 @ suttercain - on the contrary - 'prfessionally' designed sites shoudl work regadless of platform/client and convey information in an organized and structured manner. Document effects (those bits javascript can do) shoudl NOT be a pre-requisite of using the site. Fi you want to 'get with the times' I suggest you develop sites that still work without javascript. Quote Link to comment https://forums.phpfreaks.com/topic/75654-redirect-question/#findComment-382861 Share on other sites More sharing options...
GingerRobot Posted November 1, 2007 Share Posted November 1, 2007 Not only that, what about the increasing number of people accessing on phones/PDAs? There's plenty of people using the internet without javascript support. Quote Link to comment https://forums.phpfreaks.com/topic/75654-redirect-question/#findComment-382863 Share on other sites More sharing options...
PHP_PhREEEk Posted November 1, 2007 Share Posted November 1, 2007 The JS is probably fine for a little admin script... but I would agree that if a solution exists that isn't client-side dependent, that would always be preferred. After all, anytime you hit a JS redirect, the webmaster usually provides a "If your browser doesn't automatically redirect, click here." link for folks with JS disabled. PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/75654-redirect-question/#findComment-382877 Share on other sites More sharing options...
suttercain Posted November 1, 2007 Share Posted November 1, 2007 I agree with you both. But based on web statistics, is it worth all the extra time and effort? What I mean is, based on statistics for my site it would be pointless to alter JavaScript and CSS based function for older browsers and portable devices. Here are my stats for October: 8998 Unique Visitors OS 91% are running Windows. 3.8% are running Mac. 0.4% are running Linux 0.1% are running WebTV All others are below 0.1% (Sun Solaris, Free BSD, etc.) Browsers MSIE 7.0 is 36.5% Firefox 2.0 or higher 26.8% MSIE 6.0 is 26.9% Safari is 2.6% Netscape 8.0 or lower is 1.0% Opera is 0.8% Portable devices account for less than .2% At what point do we sacrifice "Bling Bling" for the small .2%? I am not trying to start a debate, but I would like some insight into this since it is something I have pondered in the past. Quote Link to comment https://forums.phpfreaks.com/topic/75654-redirect-question/#findComment-382881 Share on other sites More sharing options...
revraz Posted November 1, 2007 Share Posted November 1, 2007 Depends on what type of website you have and what type of visitors it attracts. Just because yours is .2% doesn't mean someone else's isnt 10% or more. Quote Link to comment https://forums.phpfreaks.com/topic/75654-redirect-question/#findComment-382882 Share on other sites More sharing options...
GingerRobot Posted November 1, 2007 Share Posted November 1, 2007 For the most part you dont need to sacrifice 'bling bling' for those not using a javascript enabled browser - merely provide an alternative. As was mentioned above with the 'click here' links, for example. Quote Link to comment https://forums.phpfreaks.com/topic/75654-redirect-question/#findComment-382883 Share on other sites More sharing options...
PHP_PhREEEk Posted November 1, 2007 Share Posted November 1, 2007 I agree with you both. But based on web statistics, is it worth all the extra time and effort? Well, first of all, your stats aren't concrete. Maybe .2% use portables, but what percentage of your common browser types have JS disabled? You don't provide that statistic, and I think we're going to get a bit above .2% now if you did. As to the question of extra time and effort... I really don't find it all that extra. In my experience, adding the bling is infinitely more labor intensive, requiring endless cross-browser testing and the inevitable 'work arounds' required. A great deal of the coders providing help here (or on any forums for that matter) do so in some sort of professional capacity. In other words, people pay us for projects. Those people generally run profit sites, and losing ANY visitors (even .2%) is not acceptable if it can be avoided. In this type of case, it CAN be avoided. For-profit sites generally never force a client to run any browser particular software, scripting, or plug-ins. Sure, we enable it for those clients who want to use it, but we never force it on those who don't. A site should run smoothly with a minimum amount of coding, and an even more minimal amount of client-side dependent anything. If you are hired to code professionally, this is pretty much expected. PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/75654-redirect-question/#findComment-382909 Share on other sites More sharing options...
suttercain Posted November 1, 2007 Share Posted November 1, 2007 Hi guys, Thanks for the replies. Again... I agree with you. But to touch on PhREEEk's two points: 1. According to my site stats it states "Browsers with JavaScript Disabled - 0%", I am not making this up, this is what it says. 2. .2% of 9889 is 18 people. I understand most 'for profit' sites want to keep as many people as they can, but in reality 18 out of 9889 is nothing. If I had 9889 dollars and I lost 18, I'd live... even with a for profit site. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/75654-redirect-question/#findComment-382925 Share on other sites More sharing options...
ToonMariner Posted November 2, 2007 Share Posted November 2, 2007 I agree with you both. But based on web statistics, is it worth all the extra time and effort? What extra effort?? You code your site to just work - the extra time and effort is rolling some EXTRA js to put the bells and whistles on!!! Quote Link to comment https://forums.phpfreaks.com/topic/75654-redirect-question/#findComment-383396 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.