AsiaUnderworld Posted April 10, 2009 Share Posted April 10, 2009 Hi there, im using the php mail function to send an email after a form is run, however when i get the email, it just says Dear 'Array', and hello Array , rather than the printed username, it also says Undefined index: email in /home/vheissu/public_html/feedback.php on line 20 Undefined index: email in /home/vheissu/public_html/feedback.php on line 47 both of these lines are : $email = $_POST['email']; otherwise here is the code <? $id = (int) $_SESSION['user_id']; $email = $_POST['email']; if(isset($_POST['submit'])) { $topic = mysql_real_escape_string($_POST['topic']); $ticket = mysql_real_escape_string($_POST['ticket']); if (strlen($topic) < 1) echo "<div align=center>Please enter a topic</div>"; elseif(strlen($ticket) < 1) echo "<div align=center>Please Enter ticket information</div>"; else { $sql = mysql_query("INSERT INTO helpdesk (topic,message,user) VALUES ('$topic','$ticket','".mysql_real_escape_string($id)."')"); if($sql) echo "<div align=center>Ticket submitted</div>"; else echo "<div align=center>There is a problem sending the ticket</div>"; } } $id = (int) $_SESSION['user_id']; $sql2 = mysql_query("SELECT username FROM user_details WHERE id = '".mysql_real_escape_string($id)."'"); $username = mysql_fetch_assoc($sql2); $email = $_POST['email']; $subject = "American Gangsters"; $message = "Dear '".$username."', Hello $username , thank you for signing up with American Gangsters Your Feedback is important to us. This is an automated response, please do not reply!"; mail($email, $subject, $message, "From: American Gangsters<payments@americangangsters.org>"); ?> Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted April 10, 2009 Share Posted April 10, 2009 that's because mysql_fetch_assoc, fetches an associative array you would need to use $username['username']; plus $_POST['email'] doesnt' exists. try print_r($_POST); at the top of your page you'll see what I'm talking about Quote Link to comment Share on other sites More sharing options...
AsiaUnderworld Posted April 10, 2009 Author Share Posted April 10, 2009 surely theres some bit missing from the code you've just suggesteD? i have a textbox input called email Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted April 10, 2009 Share Posted April 10, 2009 Really....you don't say. I would try putting what I put for $username in place of $username. And then put print_r($_POST) at the top of your script. Quote Link to comment Share on other sites More sharing options...
AsiaUnderworld Posted April 10, 2009 Author Share Posted April 10, 2009 [just realised ive been an idiot, and attempting a fix now] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.