Jump to content

Redirect Question


netpants

Recommended Posts

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()); 

   


?> 

Link to comment
Share on other sites

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
}

Link to comment
Share on other sites

@ 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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

 

 

 

 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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