+ Reply to Thread
Results 1 to 9 of 9
Like Tree2Likes
  • 1 Post By buddaman
  • 1 Post By lemon-tree

Thread: Trouble with PHP script works in IE but not safari or firefox

  1. #1
    buddaman is offline x10Hosting Member buddaman is an unknown quantity at this point
    Join Date
    Apr 2010
    Location
    UK
    Posts
    4

    Trouble with PHP script works in IE but not safari or firefox

    Hello everyone, hope everybody is doing well and if anyone can help me with the script i would be very grateful. This is project i've been set for University and its a simple form for students to fill out and the information goes into a database and a tutor can access the database and retrieve any information passed to it. So reasonably simple but for some reason i when i hit submit on Safari and firefox the information inputed into the form is not reflected back to the user but it is in Internet Explorer. Is there anything wrong with my script or is it a browser setting. I'm just very confused as it seems to work fine for one browser but not for another. The script is below(included HTML as did'nt know if that has anything to do with it) any ideas or solutions are greatly received.


    <head>
    <title>feedbackconfirmation</title>
    <meta name="generator" content="BBEdit 9.3" />
    </head>
    <body>
    <h1>Feedback Confirmation</h1>

    <p>Thank you for taking the time to fill in the form. The information below will be
    passed to the tutors.</p>
    <div class="articles">
    <?php

    $firstname = $_POST["firstname"];
    $lastname = $_POST["lastname"];
    $dob = $_POST["dob"];
    $comments = $_POST["comments"];
    $module = $_POST["module"];
    $session = $_POST["session"];

    // Print the content of the PHP variables back to the user

    print "<br /><br />First name is>><strong><b> $firstname</b></strong>\n";
    print "<br />Last name is>><strong><b> $lastname</b></strong>\n";
    print "<br />Date of birth is>><strong><b> $dob</b></strong>\n";
    print "<br />Your comments are>><strong><b> $comments</b></strong>\n";
    print "<br />Your module is>><strong><b> $module</b></strong>\n";
    print "<br />You selected>><strong><b> $session</b></strong>\n";
    print "<br /><br />";


    $dbserverIP="localhost";
    $dbusername="buddaman_woody";
    $dbuserpassword="PASSWORD";
    $connection=mysql_connect($dbserverIP,$dbusername, $dbuserpassword)or die("Couldn't connect to the dbserver.");

    $dbname="buddaman_classlist";
    $dbselectok=mysql_select_db($dbname,$connection) or die("Couldn't select the remote database.");

    $sqlstatement="INSERT INTO classlist VALUES ('$firstname','$lastname','$dob','$comments','$mod ule','$session')";
    $sql_result=mysql_query($sqlstatement,$connection) or die("Couldn't execute the SQL SELECT statement 1");

    $sqlstatement = "SELECT * FROM classlist";
    $sql_result = mysql_query($sqlstatement,$connection) or die("Couldn't execute the SQL SELECT statement 2");




    ?></div>

    <p> Thank you </p>

    <a href="FirstPage1.htm">Back to Homepage</a>


    Thank you all for any suggestions in advance.
    dinomirt96 likes this.

  2. #2
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: Trouble with PHP script works in IE but not safari or firefox

    Are the values actually inserted into the database?
    The browser really will not make a difference to the execution of PHP code, as PHP is a server side language. What is the URL of the page?

  3. #3
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Trouble with PHP script works in IE but not safari or firefox

    Post the html for the input form.

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Trouble with PHP script works in IE but not safari or firefox

    • When posting code, use [code], [html] or [php] (as appropriate) to separate the code from the rest of the post and format it.
    • Include a link to a live page. This is essential for this particular problem.
    • Never directly interpolate variables from user input into a query string; it leaves you open to SQL injection. Instead, use a newer driver that supports prepared statements, such as PDO. Prepared statement parameters are invulnerable to SQL injection.
    • Don't use or die
    • HTML defines the structure of a document. <br/> isn't structural, so should be avoided. Better would be to use a list in this case, such as <ul>. The best list to use here is <dl>, the definition list.
    • Read the sig and follow all instructions that apply.
    Last edited by misson; 05-09-2010 at 04:52 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  5. #5
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: Trouble with PHP script works in IE but not safari or firefox

    These are probably your problem:
    print "<br /><br />First name is>><strong><b> $firstname</b></strong>\n";
    Replace every occurrence of >> with &gt;&gt; like so:
    print "<br /><br />First name is&gt;&gt;<strong><b> $firstname</b></strong>\n";
    You also do not appear to have fully compliant HTML, you need <html> tags and proper closing of all opened tags.
    All that together makes this:
    HTML Code:
    <html>
    <head>
    <title>feedbackconfirmation</title>
    <meta name="generator" content="BBEdit 9.3" />
    </head>
    <body>
    <h1>Feedback Confirmation</h1>
    
    <p>Thank you for taking the time to fill in the form. The information below will be
    passed to the tutors.</p>
    <div class="articles">
    <?php
    
    $firstname = $_POST["firstname"];
    $lastname = $_POST["lastname"];
    $dob = $_POST["dob"];
    $comments = $_POST["comments"];
    $module = $_POST["module"];
    $session = $_POST["session"];
    
    // Print the content of the PHP variables back to the user
    
    print "<br /><br />First name is&gt;&gt;<strong><b> $firstname</b></strong>\n";
    print "<br />Last name is&gt;&gt;<strong><b> $lastname</b></strong>\n";
    print "<br />Date of birth is&gt;&gt;<strong><b> $dob</b></strong>\n";
    print	 "<br />Your comments are&gt;&gt;<strong><b> $comments</b></strong>\n";
    print "<br />Your module is&gt;&gt;<strong><b> $module</b></strong>\n";
    print "<br />You selected&gt;&gt;<strong><b> $session</b></strong>\n";
    print "<br /><br />";
    
    
    $dbserverIP="localhost";
    $dbusername="buddaman_woody";
    $dbuserpassword="PASSWORD";
    $connection=mysql_connect($dbserverIP,$dbusername, $dbuserpassword)or die("Couldn't connect to the dbserver.");
    
    $dbname="buddaman_classlist";
    $dbselectok=mysql_select_db($dbname,$connection) or die("Couldn't select the remote database.");
    
    $sqlstatement="INSERT INTO classlist VALUES ('$firstname','$lastname','$dob','$comments','$mod ule','$session')";
    $sql_result=mysql_query($sqlstatement,$connection) or die("Couldn't execute the SQL SELECT statement 1");
    
    $sqlstatement = "SELECT * FROM classlist";
    $sql_result = mysql_query($sqlstatement,$connection) or die("Couldn't execute the SQL SELECT statement 2");
    
    
    
    
    ?></div>
    
    <p> Thank you </p>
    
    <a href="FirstPage1.htm">Back to Homepage</a>
    </body>
    <html>
    Last edited by lemon-tree; 05-09-2010 at 04:54 PM.
    karimirt47 likes this.

  6. #6
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Trouble with PHP script works in IE but not safari or firefox

    Quote Originally Posted by lemon-tree View Post
    Replace every occurrence of >> with &gt;&gt; like so:
    Good advice, but > doesn't cause problems the same way that < does.

  7. #7
    buddaman is offline x10Hosting Member buddaman is an unknown quantity at this point
    Join Date
    Apr 2010
    Location
    UK
    Posts
    4

    Re: Trouble with PHP script works in IE but not safari or firefox

    In answer to a few questions yes the values are inserted into the database and the url is
    http://iainwood.x10hosting.com and you would need to click on Firstpage1.htm and then just click on Students click here. The site is not finished and is very messy but i am focusing on getting the php script to work and then i can add a CSS file and tidy it all up. I am still new to php and programming in general so i really thank you for all the help. Below is the html script for the form.

    </head>
    <h1>Feedback for Students.</h1>

    <body>
    <p>Please fill out the form below and click sumit when finished.</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>Please pick from the following<p>
    <div class="articles">
    <form name="info" action="script1.php" method="post" onsubmit="return validate_form();" >
    Module:
    <select name="module">
    <option value>Choose module</option>
    <option value>MWD1001</option>
    <option value>MWD1002</option>
    <option value>MWD1014</option>
    <option value>MWD1003</option>
    <option value>MWD1004</option>
    <option value>MWD1000</option>
    </select>
    </br>
    Session:
    <select name="session">
    <option value>Choose session</option>
    <option vlaue>Session 1</option>
    <option value>Session 2</option>
    <option value>Session 3</option>
    <option value>Session 4</option>
    <option value>Session 5</option>
    <option value>Session 6</option>
    </select>
    </br>
    First Name:
    <input type="text" name="firstname" size="12" mazlength="20"/>
    </br>
    Last Name:
    <input type="text" name="lastname"size="12" mazlength="20"/>
    </br>
    Date of birth:
    <input type="text" name="date of birth"size="12" mazlength="20"/>
    </br>
    Comments:
    <textarea name="comments" Cols=40 rows=10/></textarea>
    </br>

    <input type="reset" type="button" value="clear form">
    </br>
    <a href="script1.php"><input type="submit" type="button" value"submit information"></a>
    </form></div>

    </br>
    </br>
    </br>
    <a href="FirstPage1.htm">Back to Homepage</a>
    </body>

  8. #8
    bahawkid is offline x10Hosting Member bahawkid is an unknown quantity at this point
    Join Date
    May 2010
    Posts
    3

    Re: Trouble with PHP script works in IE but not safari or firefox

    just remove the link on this line:
    <a href="script1.php"><input type="submit" type="button" value"submit information"></a>

    it should be:
    <input type="submit" type="button" value"submit information">

    then your all fine :D

  9. #9
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Trouble with PHP script works in IE but not safari or firefox

    • Give the URL for a page (e.g. http://iainwood.x10hosting.com/SecondPage.htm) or link to the page rather than instructions on how to get there. It shouldn't be a treasure hunt.
    • Don't forget those [code], [php] and [html] tags when posting:
      PHP Code:
      <?php
      include_once('LocalDB.php');

      $fields = array(
        
      'firstname' => 'First Name''lastname' => 'Last Name'
        
      'dob' => 'Date of Birth''comments' => 'Comments'
        
      'module' => 'Module''session' => 'Session'
      );

      ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
         "http://www.w3.org/TR/html4/loose.dtd">
      <html>
        <head>
          <title>Feedback Confirmation</title>
        </head>
        <body>
          <dl>
            <?php foreach ($fields as $name => $label) {
              
      $args[":$name"] = $_POST[$name];
              
      ?>
              <dt><?php echo $name?></dt><dd><?php echo $_POST[$name]; ?></dd>
            <?php ?>
          </dl>
          <div id="Results"><?php
            
      try {
                
      $db LocalDB::connect('buddaman_classlist');
                
      $insertComment $db->prepare("INSERT INTO 
                           classlist (`firstName`, `lastName`, `dob`, `comment`, `module`, `session`) 
                           VALUES (:first,:last,:dob,:comment,:module,:session)"
      );
                if (! 
      $insertComment->execute($args)) {
                    
      $err $insertComment->errorInfo();
                    
      $exc PDOException($err[2], $err[0]);
                    
      $exc->errorInfo $err;
                    throw 
      $exc;
                }
                echo 
      "Your comment has been recorded. Thanks for your input.";
                ...
            } catch (
      PDOException $exc) {
              
      error_log($exc);
              echo 
      "I couldn't record your comment now. The error has been logged, and we'll look into it. Please try again later.";
            }
          
      ?></div>
        </body>
      </html>
      For example (and incomplete) implementations of LocalDB, see "Display all that would be secret while Mysql is broken" and "MySQL and PHP"
    Last edited by misson; 05-11-2010 at 12:30 AM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Speed Up Firefox. Really Works!
    By Jesse in forum Tutorials
    Replies: 74
    Last Post: 08-20-2011, 02:57 AM
  2. Replies: 2
    Last Post: 04-09-2010, 06:00 AM
  3. php script works elsewhere, not on x10
    By atomman in forum Programming Help
    Replies: 6
    Last Post: 01-10-2008, 08:07 AM
  4. Use Firefox/Safari? Try this.
    By Cubeform in forum Off Topic
    Replies: 21
    Last Post: 10-03-2006, 12:52 PM
  5. Script works locally but not online?!?!?!
    By oab in forum Free Hosting
    Replies: 4
    Last Post: 08-13-2006, 06:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers