Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-24-2005, 05:40 AM Sherlock Holmes would struggle
Dan Bowley's Avatar
Skilled Talker

Posts: 56
Trades: 0
Hi, I've bought webspace with a company and they sent me their own php script for email (see below). They don't accept formail or cgi for security reasons. They sent me this page below with instructions to paste it into a html editor and save as mail.php doc and change certain fields to make it work. If I try that, its a mess.

Also, the document is a html form AND php script already. How can the two be separated - obviously I want to put the form into my own html page. I've tried to paste the form into my web page and upload the rest as a php file but it doesn't work like that.

Any basic ideas on how this should be done? Does this script look dodgy to anyone else?


HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Using PHP mail()</title>
</head>
<body>

<?php

// ==================================
// Change these variables accordingly
// ==================================

$fromName = "Your name here"; // from name
$from = "Message from here (email address)"; // from address
$reply = "Reply to address (email address)"; // reply-to address

// ==================================
if($_POST['submit'] && $_POST['submit'] == "sendmail")
{
// ==================================
// Do not change these variables
// ==================================
$to = $_POST['to'];
$sub = $_POST['sub'];
$mailbody = $_POST['body'];


// ==================================
// Check email address is valid
// ==================================
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$", $to)) {
echo "<p><b>Not a valid email address, please go back and try again</b></p>";

exit;
}


// ==================================
// Send the email
// ==================================
$mailheaders .= "Content-Type: text/plain; charset=charset=iso-8859-1\n";
$mailheaders .= "From: " . $fromName . "<".$from.">\n";
$mailheaders .= "Reply-To: ".$reply.""."\n";

if(mail($to,$sub,$mailbody,$mailheaders))
echo "<p><b>Message Sent</b>";

else
echo "<p><b>Unexpected Error! Message Not Sent</b>";


}

// ==================================
// Show the HTML form
// ==================================
?>

<p><b>Send a message using PHP mail()</b></p>

<form action="<?php echo $PHP_SELF; ?>" method="post">
To:<br>
<input type="text" name="to" size="40"><br>
Subject:<br>
<input type="text" name="sub" size="40"><br>
Message:<br>
<textarea name="body" cols="50" rows="10">
Enter your message here
</textarea><br><br>
<input type="submit" name="submit" value="sendmail">
</form>


</body>
</html>

Last edited by Dan Bowley; 06-24-2005 at 09:24 AM.. Reason: better title
Dan Bowley is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-25-2005, 01:02 PM
Novice Talker

Posts: 7
Trades: 0
Hi,

just read:

// ==================================
// Change these variables accordingly
// ==================================

$fromName = "Your name here"; // from name
$from = "Message from here (email address)"; // from address
$reply = "Reply to address (email address)"; // reply-to address

What is not working?
Lutz-Development is offline
Reply With Quote
View Public Profile
 
Old 06-25-2005, 02:03 PM
reli4nt's Avatar
Extreme Talker

Posts: 168
Location: New York
Trades: 0
you may have an easier time swaping the html form at the end to match you page. Just make certain that you leave the field names the same.

separating the php is going give you headaches all week.

just direct the browser to this file (remembering the .php exrtension) and you should be fine.
__________________

Please login or register to view this content. Registration is FREE

Designing the world we live in.
Defining the terms we live by.
reli4nt is offline
Reply With Quote
View Public Profile Visit reli4nt's homepage!
 
Old 06-26-2005, 06:51 AM
Dan Bowley's Avatar
Skilled Talker

Posts: 56
Trades: 0
OK I'll try that, thanks
Dan Bowley is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Mailform
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13194 seconds with 12 queries