Jump to content

[SOLVED] Insert to MySQL DB from Form - PLEASE HELP MEEE!


azonicds2

Recommended Posts

Hi guys,

 

Ive come here because i am 100% stumped with this. Basically its just a simple insert into my SQL database from a form in an admin section.

 

I have a form in the admin page, that submits to a page called:

addResult.php

 

The addResult.php page picks up the information from the form and assigns the fields to variables.

 

Then i am attempting to submit these into the database....then the page headers to a notification page. Easy right?? lol...

 

Well ive done scripts like this one before, and never had any problems. Never with this many fields before...(9 to be exact) but that shouldnt be a problem should it?

 

Anyway ive looked over and over at this for hours, tried different ways of writing the code. Triple checked all form field names, id's and DB field names etc... Everything....

 

Basically the form submits gets to the addResult.php page and stops... A blank page appears, no errors, no warnings, nothing...

 

The action/insert code is as follows:

 

<?php
include ('connection.php')
?>
<?php
error_reporting(E_ALL);

if(isset($_POST['addResult']))
{
   $date = $_POST['betdate'];
   $bet = $_POST['bet'];
   $odds = $_POST['odds'];
   $result = $_POST['result'];
   $pl = $_POST['pl'];
   $totalpl = $_POST['totalpl'];
   $lstakes = $_POST['hundredls'];
   
if(!get_magic_quotes_gpc())
   {
      $date = addslashes($date);
      $bet = addslashes($bet);
      $odds = addslashes($odds);      
      $result = addslashes($result);
      $pl = addslashes($pl);
      $totalpl = addslashes($totalpl);
      $lstakes = addslashes($lstakes);
   }

   $query = " INSERT INTO results (Date, Bet, Odds, Result, PL, Totalpl, Lstakes) ".
            " VALUES ('$date', '$bet', '$odds', '$result', '$pl', '$totalpl', '$lstakes')";
   mysql_query($query) or die('Error ,query failed');

header("Location: resultAdded.php?"."ResultID=". mysql_insert_id($connection));
}
?>

 

 

Any help with this would be greatly greatly appretiated.

 

Thanks alot in advance.

 

Danny

Heres my form code:

 

<form id="addResult" name="addResult" method="post" action="addResult.php">
		      <table width="581" align="left" border="0">
                    <tr>
                      <td width="69" class="newstitle">Date:</td>
                      <td width="4"> </td>
                      <td width="494"><input name="betdate" type="text" id="betdate" value="<?php print date('d/m/y');?>" size="15"/></td>
                    </tr>
                    <tr>
                      <td class="newstitle">Bet:</td>
                      <td> </td>
                      <td><input name="bet" type="text" id="bet" size="50" /></td>
                    </tr>
                    <tr>
                      <td class="newstitle">Odds:</td>
                      <td> </td>
                      <td><input name="odds" type="text" id="odds" size="15" /></td>
                    </tr>
                    <tr>
                      <td class="newstitle">Result:</td>
                      <td> </td>
                      <td><input name="result" type="text" id="result" size="15" /></td>
                    </tr>
                    <tr>
                      <td class="newstitle">P+L:</td>
                      <td> </td>
                      <td><input name="pl" type="text" id="pl" size="15" /></td>
                    </tr>
                    <tr>
                      <td class="newstitle">Total P+L: </td>
                      <td> </td>
                      <td><input name="totalpl" type="text" id="totalpl" size="15" /></td>
                    </tr>
                    <tr>
                      <td class="newstitle">To £100 LS:</td>
                      <td> </td>
                      <td><input name="hundredls" type="text" id="hundredls" size="15" /></td>
                    </tr>
                    <tr>
                      <td colspan="3" class="stattext"> </td>
                    </tr>
                    <tr>
                      <td colspan="3"><span class="stattext">
                        <input type="submit" name="Submit2" value="Add Result" />
                      </span></td>
                    </tr>
                 </table>
</form>

But i thought the post part was set in the form:

 

<form id="addResult" name="addResult" method="post" action="addResult.php">

 

Ive done scripts like this before and only ever had the submit button with a name and id.

 

??

 

Thanks alot

 

Danny

Ok, all ive just done is switched the name and id of the button to "addResult" and now its working perfectly. I cant believe i was been so dumb as to not see that.

 

Guess its just really good to have a fresh pair of eyes look at your code to pick things out.

 

Thank you so very much PFMaBiSmAd

 

Danny

 

 

Archived

This topic is now archived and is closed to further replies.

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