Jump to content

Recommended Posts

Hi all,

I want our teachers to fill a form to ensure subject is entered correctly in gmail (Google Apps for Education) account.

After form is filled, I'd like teachers own web based email to open from mailto with the compose mail page they are accustomed to. (I know mailto works without issue because all our teachers are logged into Google Apps accounts and using Chrome.)

 

Here is what I have:

 

<?php
$code = check_input($_POST['code'],"Please go BACK and choose your building!");
$room = check_input($_POST['room'],"Please go BACK and enter your room #!");
$name = check_input($_POST['name'],"Please go BACK and enter your name!");
$date = date('Ymd/his', time());
?>
 
<a href="mailto:support@kinnschools.org?subject=<?php echo $code-$room $name - $date; ?>Send Email</a>
 

 

This is what I get:

 

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /home/content/05/7490705/html/service_request_forms/csform/send.php on line 8

 

I'm new to this.

What am I missing?

 

Note: line 8 begins with <a href=...

 

send.php

index.html

Here PHP thinks you are trying to do two mathematical operations on the variables <?php echo $code-$room $name - $date; ?>

 

You need to either use the concatenation operator to join the variables together or wrap them in double quotes to form subject in the mailto: 

Concatenation
<a href="mailto:support@kinnschools.org?subject=<?php echo $code.'-'.$room.' '.$name.' - '.$date; ?>">Send Email</a>

Double quotes
<a href="mailto:support@kinnschools.org?subject=<?php echo "$code-$room $name - $date"; ?>">Send Email</a>

Hello again.

 

I'm still working on my code for my service requests at work.

Thanks to Ch0cu3r for all the help, my form works as expected.

 

Now I'm considering streamlining the teachers interaction by bypassing the second link they'd have to click to get to their email.

 

I'm thinking I should instead be using fopen, but I'm not sure. I'm still getting a T_VARIABLE error in that line.

 

I'm barely above water here. Please let me know what else I'm doing wrong or what is superfluous...

Here's what I've got:

 

<?php
$code = check_input($_POST['code'],"Please go BACK and choose your building!");
$room = check_input($_POST['room'],"Please go BACK and enter your room #!");
$name = check_input($_POST['name'],"Please go BACK and enter your name!");
$date = date('Ymd/his', time());
?>
 
<?php
$handle = fopen("mailto:support@kinnschools.org?subject=<?php echo "$code-$room $name - $date"; ?>");
?>
 
 
<?php
function check_input($data, $empty='')
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    if ($empty && strlen($data) == 0)
    {
        die($empty);
    }
    return $data;
}
?>

Maybe I'm going about this all wrong...

 

Should my first link for my teachers just go to a PHP document with embedded HTML that collects the data and acts on it to prefill the subject in their email once the 'Send' button is clicked?

 

Perhaps my whole index.html file is superfluous...

No you cant do that. fopen() is for opening files located on the server not for launching the users default mail application on their computer.

 

If you do not want the user to click the email link then get PHP to send the email (using mail or use phpmailer), if their is no need to have the email open up in the users email client. Or if the user must send the email through their email client then use javascript to process the form and not PHP.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.