Php not inserting values into database
Posted: Thu Jun 18, 2009 4:35 am
Ok I've got a form, with a drop down menu and my code appears to be happy enough when running a echo $sql however theres no input into my database, but theres no error either the code runs fine and happily redirects to my new page.
here my html form:
And heres my corresponding php code:
Thanks in advance
Aravona
here my html form:
Code: Select all
<form action= "CreateChar.php" method="post">
<span class="style1">Character name:</span>
<input name="txtCharName" type="text" size="20" />
<br />
<br />
<span class="style1">Character Class:</span>
<select name="selCharClass">
<option value="Warrior" selected="selected">Warrior</option>
<option value="Mage" >Mage</option>
</select>
<br />
<br />
<input name="Create" type="submit" />
</form>Code: Select all
<?php
$link = mysql_connect('localhost','root','');
mysql_select_db('gametest',$link);
$CharClass = $_POST['selCharClass'];
$sql = "INSERT INTO characters (CharName, Charclass) ";
$sql = $sql . " values ('$_POST[txtCharName]', '$CharClass')";
// echo $sql;
echo "You have chosen your character.";
?>Aravona