FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


mail problems





cLean
Code:

<form action="<?php echo $_SERVER['PHP_SELF']; ?> method="POST">

Name: <Input type="text" name="visname">
<br>
Email: <input type="text" name="visemail">
<br>
Fill in below your words:
<br>
<textarea rows="8" cols="50" name="visprob"> Contact Us Here </textarea>
<br>
<br>
<input type="submit" value="Submit">
</form>
<?php

$companyemail = 'support@fragn.frihost.net';
mail('$companyemail', '$visname Contact US', 'Name: $visname Email: $visemail Words of Mouth: $visprob' );
header( 'Location: http://xpcpro.net/thanksforthewords.php' );

?>


This code is not sending me anything to my email
and whats wrong with my header?
rvec
headers only work if no html is send to the browser, and you should use "" instead of '' if you want to put variables in.
Also you might want to make sure the filled in mail address is an actuall mail adress with the php filter function http://nl.php.net/manual/en/function.filter-var.php

Then you have to read about the $_POST superglobal and use that instead of the variables with the formnames
cLean
Code:

<-- Contact US -->



<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">



Name: <Input type="text" name="visname">

<br>

Email: <input type="text" name="visemail">

<br>

Fill in below your words:

<br>

<textarea rows="8" cols="50" name="visprob"> Contact Us Here </textarea>

<br>

<br>

<input type="submit" value="Submit">

</form>

<?php
$visname = $_POST['visname'];
$visemail = $_POST['visemail'];
$visprob = $_POST['visprob'];

$headers = "Name: $visname";
$headers .= "Email: $visemail";
$headers .= "Words of Mouth: $visprob";



$companyemail = "support@fragn.frihost.net";


mail("$companyemail", "$visname Contact US", "$headers" );

header( "Location: http://xpcpro.net/thanksforthewords.php" );



?>



I got everything to work but I dont get you on why the header() doesn't work. Now in my email it shows up as 1 line ive tried inserting. <br>'s /n's what else should i try and were should i place these?

If their is no way to get the header to work. how can i get the submit button to goto a page that auto directs to previous page.. or home page or whatever i choose..
kv
header() doesn't work because you have html output before the header call. Put your form in a if condition.

Here is a corrected version
Code:

<?
if(!isset($_POST)) //if form is not submitted, render form
{
?>
<!-- include all your html here like <html><body> etc -->
<html>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">



Name: <Input type="text" name="visname">

<br>

Email: <input type="text" name="visemail">

<br>

Fill in below your words:

<br>

<textarea rows="8" cols="50" name="visprob"> Contact Us Here </textarea>

<br>

<br>

<input type="submit" value="Submit">

</form>

</body>
</html>

<?
}
else //if form submitted, send mail and redirect
{
$visname = $_POST['visname'];
$visemail = $_POST['visemail'];
$visprob = $_POST['visprob'];

$headers = "Name: $visname";
$headers .= "Email: $visemail";
$headers .= "Words of Mouth: $visprob";



$companyemail = "support@fragn.frihost.net";


mail("$companyemail", "$visname Contact US", "$headers" );

header( "Location: http://xpcpro.net/thanksforthewords.php" );

}

?>
rvec
please don't use that script for anything besides testing and trying out. It is really easy to spam with that script and send loads of spam to loads of addresses.
Related topics
e-mail problems
form mail problems (quality help=frih$)
PHP mail problems...
problems with mail()
Server 2 POP mail problems
Unable sending mail - verification error
Mail problems on VPS1
Sorry......E-mail not working
Setting up E-mail Problems
Malicious script I can't seem to get rid of...
Problems Logging into Squirrel Mail
Anyone else having problems with Yahoo Website and Mail?
New Server - POP3 Emails Not Received
Exim, spamblocker and spamassassin changes on Server 2/3
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.