Hi guys
Trying to post the values of the checkbox into the database
I think im almost there but something is stopping it going into the database
PHP Code:<form method="post" action="<?php print $_SELF; ?>">
Avon:<input type="checkbox" value="avon" name="location[]">:<br />
Bedfordshire:<input type="checkbox" value="Bedfordshire" name="location[]">:<br />
Buckinghamshire:<input type="checkbox" value="Buckinghamshire" name="location[]">:<br />
Cambridgeshire:<input type="checkbox" value="Cambridgeshire" name="location[]">:<br />
Cheshire:<input type="checkbox" value="Cheshire" name="location[]">:<br />
<input type="submit" name="submit_alert value="Submit Job" />
PHP Code:<?PHP
//connect to your database ** EDIT REQUIRED HERE **
$connection = mysql_connect("localhost","notexper_two","three"); //(host, username, password)
//specify database ** EDIT REQUIRED HERE **
mysql_select_db("notexper_one") or die("Unable to select database"); //select which database we're using
if(isset($_POST['submit_alert']))
{
$location = implode(',',$_POST['location']);
$sql = "INSERT INTO jobalerts (location, location1, location2, location3, location4, location5) VALUES ('".$location."')";
mysql_query($sql);
}
?>








Bookmarks