Here is my PHP code:
// Collect data from URL
$mid = $_GET['m'];
if (isset($_POST['submit']))
{
$insert = "insert into table SET from_id = '".$loginuser['members_id']."', to_id = '". $mid ."', date = '".$_POST['date']."' ";
$add_member = mysql_query($insert);
}
The data gets entered in the database correctly except the $mid
But if in my HTML I put this :
<?php print $mid;?>
Then i can see the print of the ID number ... so I know my variable $mid has the proper value.... I don't know why it not getting inserted in the DB.
I also tried this SQL
$insert = "insert into table SET from_id = '".$loginuser['members_id']."', to_id = "$mid", date = '".$_POST['date']."' ";
$add_member = mysql_query($insert);
Same thing... everything works except the value of $mid doesn't go in the DB.
My field in the DB is set to Int(11) and there is no mistake in the column name.. i checked 5 times... Don'T know what's wrong.. thx
ENTIRE CODE HERE :
<?
ob_start();
include 'datalogin.php';
//checks cookies to make sure they are logged in
if(isset($_COOKIE["user"]))
{
$username = $_COOKIE["user"];
$pass = $_COOKIE["password"];
$check = mysql_query("SELECT * FROM members WHERE email = '$username'")or die(mysql_error());
$loginuser = false;
while($info = mysql_fetch_array( $check ))
{
if(! $loginuser)
{ $loginuser = $info; }
//if the cookie is present but has the wrong password, they are taken to the login page
if ($pass != $info['password'])
{
header("Location: login.php");
exit();
}
else //if the cookie is present and doesn'T have the wrong password they are shown the admin area
{
include 'header.php';
}
}
}
else //if there is no cookie present
{
header("Location: login.php");
exit();
}
// Collects data from images table
$mid = $_GET['m'];
$data = mysql_query("SELECT images.image_id, images.members_id, images.image_url, members.members_id, members.name, members.age
FROM members
LEFT JOIN images
ON members.members_id=images.members_id WHERE members.members_id ='". $mid ."' ")
or die(mysql_error());
$data2 = mysql_fetch_array( $data );
if (isset($_POST['submit']))
{
$insert = "insert into booking SET from_id = '".$loginuser['members_id']."', to_id = '$mid', date = '".$_POST['date']."'";
$add_member = mysql_query($insert) or die(mysql_error());
header('Location: index.php');
exit();
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" >
<table cellspacing='0' id="booking" align="center" width="680">
<tr>
<td>Date:</td>
<td><input name="date" type="text" size="10" maxlength="10" class="form-field" /> </td>
</tr>
<tr>
<td> </td>
<td><input class="submit-button" type="submit" name="submit" value="SEND REQUEST" /></td>
</tr>
</table>
</form>
<br />
HERE IS THE TABLE STRUCTURE
CREATE TABLE IF NOT EXISTS `booking` (
`booking_id` int(11) NOT NULL AUTO_INCREMENT,
`from_id` int(11) NOT NULL,
`to_id` int(11) NOT NULL,
`date` varchar(10) NOT NULL,
PRIMARY KEY (`booking_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=17 ;