Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 3 of 3 FirstFirst 123
Results 31 to 35 of 35
  1. #31
    New Coder
    Join Date
    May 2012
    Posts
    20
    Thanks
    6
    Thanked 0 Times in 0 Posts
    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";
    }

    }

    ?>

  2. #32
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    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).

  3. Users who have thanked Fou-Lu for this post:

    Salman1990 (06-19-2012)

  4. #33
    New Coder
    Join Date
    May 2012
    Posts
    20
    Thanks
    6
    Thanked 0 Times in 0 Posts
    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 ??

  5. #34
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    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

  6. Users who have thanked Fou-Lu for this post:

    Salman1990 (06-19-2012)

  7. #35
    New Coder
    Join Date
    May 2012
    Posts
    20
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Thanks for all your generosity in these last 2 months I would like you to close this topic


 
Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •