Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-18-2012, 04:25 PM   PM User | #31
Salman1990
New Coder

 
Join Date: May 2012
Posts: 20
Thanks: 6
Thanked 0 Times in 0 Posts
Salman1990 is an unknown quantity at this point
What i am trying to do is to select a tutor from the list and send the email but like you said it sends the email to the last tutor of the list dont I just need if option value has been selected wouldnt that be much easier rather than having a javascript?

Note : I re-edited the code and inserted everything into the php

PHP Code:
<?php

session_start
();


$link mysql_connect('********''********''********');
mysql_select_db('********');
if(
$_SESSION['student_id'])
$studentID=$_SESSION['student_id'];

$query mysql_query("Select * from students where Student_ID='$studentID'");
while(
$row=mysql_fetch_assoc($query))
{
$studentemail=$row['Student_Email'];
}
//echo "The student email is: $studentemail";

echo "<form action='testing.php' method='POST'>";
echo 
"<br>";
$result3 mysql_query("SELECT * from tutors") or die(mysql_error());
while (
$rows mysql_fetch_assoc($result3))
{
//$tutorFname=$rows["Tutor_FName"];
//$tutorLname=$rows["Tutor_LName"];
$tutoremail=$rows['Tutor_Email'];
$options.= '<option value="'.$rows['Tutor_ID'].'">'.$rows['Tutor_FName']." ".$rows['Tutor_LName'].'</option>';
}
echo 
"<select name=Tutor_Email>";
echo 
"<option value=''>Choose</option>";
echo 
$options;
echo 
"</select>";
echo 
"<input type='submit' name='submit' value = 'Send Email'>";
echo 
"</form>";
$submit=$_POST['submit'];


if(
$submit)
{
if(
$options)
{
mail($tutoremail,"message","title","From:$studentemail");
echo 
"Message has been sent";
}
else
{
echo 
"select a tutor";
}

}

?>
Salman1990 is offline   Reply With Quote
Old 06-18-2012, 07:22 PM   PM User | #32
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
PHP Code:
mail($tutoremail,"message","title","From:$studentemail"); 
$tutoremail is provided by the last iteration of the recordset. The data you need comes from $_POST['Tutor_Email'], but this is the Tutor_ID as specified in the Option value. You need to select the email from the db where the Tutor_ID = (int)$_POST['Tutor_Email'] (assuming its an integer).
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Salman1990 (06-19-2012)
Old 06-19-2012, 03:15 PM   PM User | #33
Salman1990
New Coder

 
Join Date: May 2012
Posts: 20
Thanks: 6
Thanked 0 Times in 0 Posts
Salman1990 is an unknown quantity at this point
Thanks it works perfectly I want to ask if i want to send a link in the email do i need to pass a header ??
Salman1990 is offline   Reply With Quote
Old 06-19-2012, 03:31 PM   PM User | #34
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Quote:
Originally Posted by Salman1990 View Post
Thanks it works perfectly I want to ask if i want to send a link in the email do i need to pass a header ??
Yeah, if its using HTML you'll need to push the content type for it. Here's an example on the API for that: http://ca.php.net/manual/en/function...p#example-3152
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Salman1990 (06-19-2012)
Old 06-20-2012, 08:35 PM   PM User | #35
Salman1990
New Coder

 
Join Date: May 2012
Posts: 20
Thanks: 6
Thanked 0 Times in 0 Posts
Salman1990 is an unknown quantity at this point
Thanks for all your generosity in these last 2 months I would like you to close this topic
Salman1990 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:55 PM.


Advertisement
Log in to turn off these ads.