/    Sign up×
Community /Pin to ProfileBookmark

This was taken from an example. I copied it to Dreamweaver, saved it as default.php and uploaded it onto my site. Purely to see how it works…

[code=php]
<?php

if (isset($_REQUEST[’email’]))
//if “email” is filled out, send email
{
//send email
$email = $_REQUEST[’email’] ;
$subject = $_REQUEST[‘subject’] ;
$message = $_REQUEST[‘message’] ;
mail( “[email protected]”, “Subject: $subject”,
$message, “From: $email” );
echo “Thank you for using our mail form”;
}
else
//if “email” is not filled out, display the form
{
echo “<form method=’post’ action=’mailform.php’>
Email: <input name=’email’ type=’text’ /><br />
Subject: <input name=’subject’ type=’text’ /><br />
Message:<br />
<textarea name=’message’ rows=’15’ cols=’40’>
</textarea><br />
<input type=’submit’ />
</form>”;
}

?>
[/code]

Once I hit the submit button, I get a mailform.php error. What do I do to get this code to work so that I can see how it runs and then hopefully write my own…

to post a comment
PHP

22 Comments(s)

Copy linkTweet thisAlerts:
@mayooresanApr 08.2008 — Did you save this php file as [B]mailform.php[/B]???
Copy linkTweet thisAlerts:
@Hooded_VillianauthorApr 08.2008 — Nope... I had an HTML page, that I saved as default.php and placed the above code inside of that.
Copy linkTweet thisAlerts:
@mayooresanApr 08.2008 — You must save it as mailform.php

Cz the details are passed to the mailform.php

you can check it in the form tag
<form method='post' action='mailform.php'>[/QUOTE]
action= name of the file where you want to get and process the details of this form

Hope now the problem is solved!
Copy linkTweet thisAlerts:
@Hooded_VillianauthorApr 08.2008 — Because the file is saved as default.php I changed the below line of code from this

<form method='post' action='mailform.php'>
[/QUOTE]


to this

<form method='post' action='default.php'>
[/QUOTE]


And it works... BUT...

mail( "[email protected]", "Subject: $subject",[/QUOTE]

When I changed that line to my own email address, it still doesn't come through.
Copy linkTweet thisAlerts:
@TriZzApr 08.2008 — Hey, I'm not a PHP expert, but I saw this thread earlier (like two posts down from yours) that had a similar problem about halfway down the page.

http://www.webdeveloper.com/forum/showthread.php?t=178313

Try that out, it may work for you like it did for them.
Copy linkTweet thisAlerts:
@Hooded_VillianauthorApr 08.2008 — mail($to, $sub, $mes, $headers) or die ("There was an Error with Sending Mail via PHP."); [/QUOTE]

I saw from another thread that they added an "or die" function... Where would I put it in the script Im busy using, above?
Copy linkTweet thisAlerts:
@Hooded_VillianauthorApr 08.2008 — Thanks Trizz... I'll give it a bash.
Copy linkTweet thisAlerts:
@Hooded_VillianauthorApr 08.2008 — Still can't get this thing to work!!!
Copy linkTweet thisAlerts:
@TriZzApr 08.2008 — Sorry Hooded_Villian. I've got my own simple question here...I just figured I'd refer you to there since I had seen it earlier. Best of luck to you with the future responses from people much better at this stuff than I.
Copy linkTweet thisAlerts:
@mayooresanApr 09.2008 — Still can't get this thing to work!!![/QUOTE]
can you show me your code?

I try my best to help!
Copy linkTweet thisAlerts:
@mayooresanApr 09.2008 — <?php

if (isset($_REQUEST['email']))

//if "email" is filled out, send email

{

//send email

$email = $_
REQUEST['email'] ;

$subject = $_REQUEST['subject'] ;

$message = $_
REQUEST['message'] ;

mail( "[email protected]", "Subject: $subject",

$message, "From: $email" );

echo "Thank you for using our mail form";

}

else

//if "email" is not filled out, display the form

{

echo "<form method='post' action='mail.php'>

Email: <input name='email' type='text' /><br />

Subject: <input name='subject' type='text' /><br />

Message:<br />

<textarea name='message' rows='15' cols='40'>

</textarea><br />

<input type='submit' />

</form>";

}

?>[/QUOTE]

I tried this code and it's perfectly working for me!!!
Copy linkTweet thisAlerts:
@Hooded_VillianauthorApr 09.2008 — Dunno wtf is going on, but still cant get this thing to work...

Gonna go thru it step by step:

Go the the website I am studying from.

http://www.w3schools.com/php/php_mail.asp[/QUOTE]

Copy, Cut, Paste the script, below, from the website, to Dreamweaver.

[code=php]if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail( "[email protected]", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
[/code]


Change the lines, below, to what I need them to be.

mail( "[email protected]", "Subject: $subject", $message, "From: $email" );[/QUOTE]
echo "<form method='post' action='default.php'>[/QUOTE]

Save as default.php and upload to www.myowntestpage.com

Let's see if it works this time round.
Copy linkTweet thisAlerts:
@mayooresanApr 09.2008 — Seems ok, It should work now... check and tell me!
Copy linkTweet thisAlerts:
@Hooded_VillianauthorApr 09.2008 — O... Thats interesting. Now the form doesn't even show up.

*Puts gun to head*
Copy linkTweet thisAlerts:
@Hooded_VillianauthorApr 09.2008 — Right... Im border line giving up here. Dunno what else to do... Got everything up and running. Even put my spam filter on my hotmail account on low, and still... It says the form has been sent but nothing comes thru to my email account.

So, a friend of mine suggests this.

$TEST = mail( "[email protected]", "Subject: $subject", $message, "From: $email" ); echo $TEST;[/QUOTE]

So I do it, and get the result of number 1. Which I am assuming is true.
Copy linkTweet thisAlerts:
@mayooresanApr 09.2008 — [code=php]<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail( "[email protected]", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mail.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}

?>[/code]


save this code as mail.php!!

and then try to send the mail!!! this code is working for me.. if your hotmail is not receiving the mail try with another account.. it's working for my gmail account!!!

Don't give up!!
Copy linkTweet thisAlerts:
@Hooded_VillianauthorApr 09.2008 — [code=php]<?php

if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail( "[email protected]", "Subject: $subject",
$message, "From: $email" );
echo "Thanks for using this form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mail.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}

?>[/code]


I created a gmail account and saved the damn thing as mail.php. Then I went to my hotmail account and sent two emails to the gmail account, and those came through right away.

Wonder if its got something to do with my hosting company. I am using fasthosts.co.uk.
Copy linkTweet thisAlerts:
@Hooded_VillianauthorApr 09.2008 — Just as I thought.

Email sent from scripts must be from or to a Fasthosts-hosted email address.[/QUOTE]
Copy linkTweet thisAlerts:
@Hooded_VillianauthorApr 09.2008 — You can find the help you need in our knowledge base article "Email sent from scripts must be from or to a Fasthosts-hosted email address" at:

http://www.fasthosts.co.uk/knowledge-base/?article_id=1077

On our windows server you will need to define this command at the top of the script :

ini_set("sendmail_from", " [email][email protected][/email] ");

Thanks again for contacting us.
[/QUOTE]


This is getting really confusing now...
Copy linkTweet thisAlerts:
@Hooded_VillianauthorApr 09.2008 — OMW... IT FREAKING WORKS!!!!!!!!!!

What a mission...

Thanks for all your help. Trust me... I'll be back real soon!!!
Copy linkTweet thisAlerts:
@TheLanyardApr 09.2008 — EDIT: Whoops...you got it working. Now how do I delete this?
Copy linkTweet thisAlerts:
@mayooresanApr 10.2008 — anyway you got it work..huh? thats the spirit!! good luck!
×

Success!

Help @Hooded_Villian spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...