PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
DarkLightA
Forum Newbie
Posts: 2 Joined: Tue Jul 07, 2009 3:33 am
Post
by DarkLightA » Tue Jul 07, 2009 3:38 am
I've got this coded:
Code: Select all
<html>
<head>
<?php
$to = 'myemail@gmail.com';
$subject = '$input1' . ' -- ' . '$input2';
$message = '$input1<br />$input2';
if (mail($to, $subject, $message))
{
print 'Mail sent.';
}
?>
</head>
<body>
<form><span class="vertwenty"><img src="input1.jpg" /> </span><input class="forem" type="text" name="input1" /></form>
<form><span class="vertwenty"><img src="input2.jpg" /> </span><input class="forem" type="text" name="input2" /></form>
<br />
<br /><form><input type="image" src="submit.jpg" alt="Submit"></form>
</body>
</html>
I this I'm trying to make it send an e-mail to me, "
myemail@gmail.com " with the texts inputed in forms for input1 and input2. These two are meant to be submitted into the e-mail-sending PHP code after clicking the submit.jpg image. However, this doesn't seem to work.
The e-mail should look like this:
Subject: input1 -- input2
Message: input1
input2
Can anyone help??
DarkLightA
Forum Newbie
Posts: 2 Joined: Tue Jul 07, 2009 3:33 am
Post
by DarkLightA » Tue Jul 07, 2009 5:18 am
Ok it's like this now:
Code: Select all
<?php
$to = "site@site.site";
$subject = "Hi";
$email = "site@site.site";
$message = $_REQUEST['input1'] . ' -- ' . $REQUEST['input2'];
$headers = "Hello";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>
That is on a seperate page, called contact.php. Here's the rest:
Code: Select all
<html>
<body>
<form method="post" action="contact.php"><span class="vertwenty"><img src="user.jpg" /> </span><input class="forem" type="text" name="input1" /></form>
<form method="post" action="contact.php"><span class="vertwenty"><img src="password.jpg" /> </span><input class="forem" type="text" name="input2" /></form>
<br />
<br /><form method="post" action="contact.php"><input type="image" src="submit.jpg" alt="Submit"></form>
</body>
</html>
Can anyone help? When I type in something in the input1 form, in the input2 form and click submit, it comes up with Parse error: syntax error, unexpected T_VARIABLE in xxxxxxxxxxxx/htdocs/contact.php on line 5
phpneeds
Forum Newbie
Posts: 2 Joined: Tue Jul 07, 2009 6:19 am
Post
by phpneeds » Tue Jul 07, 2009 6:29 am
Ur mistake : u have given <form> tag for all the <input> tags.
Only one <form> tag is enough to run this code. try it now..it ill work fine
Code: Select all
<html>
<body>
<form method="post" action="contact.php"><span class="vertwenty"><img src="user.jpg" /> </span><input class="forem" type="text" name="input1" />
<span class="vertwenty"><img src="password.jpg" /> </span><input class="forem" type="text" name="input2" />
<br />
<br /><input type="image" src="submit.jpg" alt="Submit"></form>
</body>
</html>