wcology Posted June 8, 2009 Share Posted June 8, 2009 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:except 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 More sharing options...
Yvil Posted June 8, 2009 Share Posted June 8, 2009 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 More sharing options...
roundcorners Posted June 8, 2009 Share Posted June 8, 2009 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 More sharing options...
wcology Posted June 8, 2009 Author Share Posted June 8, 2009 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 More sharing options...
justsomeguy Posted June 8, 2009 Share Posted June 8, 2009 If the form is submitted through post, you can find everything in $_POST, if it's through get then you'll find it in $_GET. Check this thread:http://w3schools.invisionzone.com/index.php?showtopic=12509 Link to comment Share on other sites More sharing options...
wcology Posted June 10, 2009 Author Share Posted June 10, 2009 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 More sharing options...
smerny Posted June 10, 2009 Share Posted June 10, 2009 where are you getting subject and headers from? Link to comment Share on other sites More sharing options...
wcology Posted June 10, 2009 Author Share Posted June 10, 2009 oh forgot to delete that. here, new code: <?php$first = $_POST['first'];$last = $_POST['last'];$to = 'nobody@example.com';$message = 'subscribe ucso $first $last';mail($to, $message);?> would this work? Link to comment Share on other sites More sharing options...
smerny Posted June 10, 2009 Share Posted June 10, 2009 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 More sharing options...
wcology Posted June 10, 2009 Author Share Posted June 10, 2009 is it possible to leave it blank?like $subject = '' Link to comment Share on other sites More sharing options...
smerny Posted June 10, 2009 Share Posted June 10, 2009 why would you want a blank subject? Link to comment Share on other sites More sharing options...
Natechs Posted June 10, 2009 Share Posted June 10, 2009 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 More sharing options...
Synook Posted June 10, 2009 Share Posted June 10, 2009 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.