Jump to content

Execute Mailto With Form Input


wcology
 Share

Recommended Posts

so i know nothing about PHP and after looking around tutorials I'm still trying to get familiar with the dollar signs and all that. anyway I've got a form, looks like this:28jh7kp.pngexcept I've replaced the link with a button, and my question is, how do I construct the php code so that on clicking the button, the browser will launch a mail program like it does with "mailto" with preset text it and the form inputs at the end?

Link to comment
Share on other sites

The dollar signs are strings.I would love to help, but I have to go to school this very moment.If you're question hasn't been answered when I get back I will do so ;-).

Link to comment
Share on other sites

The dollar signs declare a variable. I.e $thisIsAVariable, and thisIsNotAVariable.If you simply want to open a mail client then continue to use a href="mailto:..., However, if you want to send the info entered in your form to a mail recipient, you'll need to harness the mail() function.Gather the form info using $_POST[fieldname] variables andadd them and several headers to the mail function and submit.for more info http://uk.php.net/manual/en/function.mail.php

Link to comment
Share on other sites

so im guessing the php code should look something like this?

<?php// The message$message = "preset text message here with form input afterwards";// Sendmail('mail recipient', 'My Subject', $message);?>

how do i link it so that it grabs input from the form?

Link to comment
Share on other sites

ok here's what I have so far:HTML:

<form id="form1" name="form1" method="post" action="join.php">  <div><br />    First name:     <input name="first" type="text" value="what do you go by" onfocus="this.value=''"/>    <br />    <br />    Last name:    <input name="last" type="text" value="your family name" onfocus="this.value=''"/>    <br />    <br />    <input name="Submit" type="submit" value="Drop us an email" />  </div></form>

and in join.php

<?php$first = $_POST['first'];$last = $_POST['last'];$to      = 'nobody@example.com';$message = 'subscribe ucso $first $last';mail($to, $subject, $message, $headers);?>

does this work?

Link to comment
Share on other sites

subject is required....try

<?php$first = $_POST['first'];$last = $_POST['last'];$to = 'nobody@example.com';$subject = 'subscription'$message = 'subscribe ucso'. $first .' '. $last;mail($to, $subscribe, $message);?>

Link to comment
Share on other sites

No. A variable can be assigned a value or be null. Like so:

<?php$subject = ""; // $subject is null as in no value$subject = "Subscribe!"; // now $subject has a value!?>

Link to comment
Share on other sites

Actually, variables are only NULL when they are not declared or assigned null. When they have zero-length content they are empty. For example:Source:

<?php	$string;	var_dump($string);	echo "<br>";	$string = "";	var_dump($string);	echo "<br>";	$string = "test";	var_dump($string);	echo "<br>";	$string = null;	var_dump($string);?>

Output:

Notice: Undefined variable: string in C:\wamp\www\lab\tests\null.php on line 3NULL string(0) "" string(4) "test" NULL
Edited by Synook
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...