ok, i am just trying to make a simple form at the moment that logs the users id and name. basically i have a form that asks for the users name and email address, it checks if the email address is registered by checking if there is an "id" present with the email address in my "user" table. I would like it to create an entry in my "crush" table with the users name and id. and if the email address does not match an id it should echo "id incorrect" or the login form. i have this code but it always echoes invalid id, even when i put the right details in:
<?php
if (!$_POST)
{
include("form.php");
}
$dbhost = 'mysql.d****.co.uk';
$dbuser = 'nextman';
$dbpass = '*****';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'main';
mysql_select_db($dbname);
$fetch=mysql_fetch_assoc(mysql_query("SELECT `id` FROM `user` WHERE `email`='$email'"));
$id = $fetch['id'];
$id = isset($_GET['id'])?$_GET['id']:0;
if ($id > 0) {
$name = $_POST['txtName'];
$email = $_POST['txtEmail'];
mysql_query("INSERT INTO `crush` (name, id) VALUES ('$name', '$id')");
include("member.php");
}
else
{
echo 'invalid entry id';
}
?>