Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP and MySQL, Submit not working in Firefox(?)

    I have a rather weird problem, and my google-fu seems to be weak at the moment.

    We've made a little script that simply sends the data in some form fields to a database, all is well when data is sent with either Opera and Internet Explorer, data is accepted and can be fetched, but in Firefox and Chrome, it won't send any data at all. Does anyone see the problem here?

    The INSERT script.

    Code:
    <?php
    $myServer = "SOMESERVER";
    $myUser = "USER";
    $myPass = "PASS";
    $myDB = "DATABASE";
        //henter data fra input-skjema
    	$gbEier = $_POST['gbEier'];
    	$gbDato = $_POST['gbDato'];
    	$gbGjestNavn = $_POST['gbGjestNavn'];
    	$gbMelding = $_POST['gbMelding'];
    
    
    $dbhandle = mysql_connect($myServer, $myUser, $myPass)
      or die("Couldn't connect to SQL Server on $myServer");
    
    
    $selected = mysql_select_db($myDB, $dbhandle)
      or die("Couldn't open database $myDB");
    
    
    $sqltxt = "INSERT INTO gjestebok(gbEier, gbDato, gbGjestNavn, gbMelding) VALUES('$gbEier', '$gbDato', '$gbGjestNavn', '$gbMelding')";
    
    
    
    $result = mysql_query($sqltxt) or die("2Couldn't open database $myDB");
    
    //stenger av etter at jobben er gjordt     
    mysql_close($dbhandle);
    echo "It's sent!";
    ?>

    The SELECT script.

    Code:
    <div class="hent">
    <?php
    $myServer = "hera.hint.no";
    $myUser = "mmt106";
    $myPass = "gDIPry1";
    $myDB = "mmt106";
    
    //connects to the server
    $dbhandle = mysql_connect($myServer, $myUser, $myPass)
      or die("Couldn't connect to SQL Server on $myServer");
    
    //selects a database
    $selected = mysql_select_db($myDB, $dbhandle)
      or die("Couldn't open database $myDB");
      
    
    $resultat = mysql_query("SELECT * FROM gjestebok WHERE gbEier='050818'") or die("Feil nummer 0 " . mysql_error()) ;
    
    
    $num = mysql_num_rows($resultat) or die("Feil nummer 1 " . mysql_error()) ; //skriver ut en fancy overskrift
    echo "<h2>" . $num . " Rad" . ($num == 1 ? "" : "er") . " ble returnert. </h2>";
    echo "<hr size='3' color='#990000'>";
    
    
    while  ($row = mysql_fetch_array($resultat)) {
    	$dato=$row[gbDato];
    	$eier=$row[gbEier];
    	$navn=$row[gbGjestNavn];
    	$melding=$row[gbMelding];
    	?> 
    	<table class="tabell" border="0" cellpadding="1" cellspacing="30" >
    	 <tr><td><?php echo $dato; ?></td>
    	<td ><?php echo $eier; ?></td>
    	 <td ><?php echo $navn; ?></td>
    	 <td ><?php echo $melding; ?></td></tr>
    	 </table>
    	<?php
    	
    }
    
    
    mysql_close($dbhandle);
    ?>
    </div>



    And finally, the webpage that contains the submit boxes.
    Code:
    <form action="hera.php" method="POST">
    <table class="skjema">
    	<tr>
    
        	<td></td><td><input id="gbEier" type="text" name="gbEier" value="050818" /></td>
    	</tr>
    	<tr>
    
        	<td><p>Dato:</p> </td><td><input id="gbDato" type="text" name="gbDato" value="" /></td>
    	</tr>
    	<tr>
    
        	<td><P>Navn:</p> </td><td><input id="gbGjestNavn" type="text" name="gbGjestNavn" value="BLANK" /></td>
    	</tr>
    	<tr>
    
        	<td><p>Melding:</p> </td><td><textarea id="gbMelding" name="gbMelding" cols="72" rows="2"></textarea></td>
    	</tr>
    	
        <tr>
        	<td colspan="2"><a href="BLANK"><input class="reg" type="submit" name="submit" value="Registrer" /></a>&nbsp;<input class="tom" type="reset" name="reset" value="Tøm skjema" />
    			</tr>    
    </table>
    </form>
    
    <form class="les" action="BLANK" method="POST">
     Les melding:&nbsp; &nbsp;<td colspan="2"><input class="melding" type="submit" name="submit" value="    X    " /></form></td>
    Last edited by Tuxxy87; 03-09-2010 at 10:48 AM.

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    the submit button needs to be inside of the close form element, ie: </form>

  • #3
    New to the CF scene
    Join Date
    Mar 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ah yes of course, how did I miss that..?

    Thank you!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •