i created a webpage with a form which submits data to a database and also sends a URL to an email address with random ID at the end which will link to specific data from the database when viewed in a browser

when i try and pull the data nothing seems to display, heres my code:

PHP Code:
<?php

// since the id is being passed in the url, you will need to declare it using the get method
$rand $_GET['rand'];
$action $_GET['action'];


// if an id was sent to the script, then execute it
if ($rand)
{
// connection vars
$host "localhost";
$user "****";
$password "****";
$dbname "****";
$tablename "cards";

// connect to and select the database
@mysql_connect($host,$user,$password) or die("&success=no&");
@
mysql_select_db($dbname) or die("&success=no&");

// query the database and return an array of data
$result = @mysql_query("SELECT * FROM $tablename WHERE rand = $rand") or die("&success=no&");




// break the array down into the parts you need
while($row mysql_fetch_array($result)){

$youremail urlencode($row['youremail']);
$name urlencode($row['name']);
    
$receiveremail urlencode($row['receiveremail']);
    
$message $row['message'];


$message str_replace('\n''\r'$message);
$message str_replace('\r\n''\r'$message);
$message str_replace('<br>''\r'$message);
$message str_replace('%0D%0A''\r'$message);


}
// if there was a result echo the stuff below
if($result)
{


echo 
"my name is "$name" my email address is ",$youremail," " ?>


<?php
exit();
}
mysql_close();
}
?>

This is how im adding to the databse

PHP Code:
// insert your data here with $rand as the id
$youremail mysql_real_escape_string($_POST['youremail']);
$name mysql_real_escape_string($_POST['name']);
$receiveremail mysql_real_escape_string($_POST['receiveremail']);
 
$message mysql_real_escape_string($_POST['message']);

 
$query="INSERT INTO $tablename (rand, youremail, name, receiveremail, message) 
 VALUES ('"
.$rand."', '".$youremail."', '".$name."', '".$receiveremail."',   '".$message."')"