Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Sponsored Reviews   Improve your ranking, submit to directories   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 09-17-2006, 05:52 AM   #1 (permalink)
Junior Member
 
Join Date: 09-17-06
Posts: 13
iTrader: 0 / 0%
Latest Blog:
None

sambkk is liked by many
I am hoping for some help.About a php contact form.

Hi
I want to make a contact form but I am having some trouble.

I always use the same code for a simple form, but on a new site with a new host, it doesnt work.

I have no idea why. I turn CGI on already.

here is the code.
PHP file:
<?
$to = "xxx@xxxx.com";
$subject = "Email from website contact form";
$boundary = uniqid("");
$headers = "From: $from";
$body = "
Name :$user
Email :$emailaddress
Comment :$comments
";
if (mail($to, $subject, $body,$headers)) {
print( "Thank you for emailing us.Your file has been sent succesfully");
?>
<meta http-equiv=refresh content="1;URL=http://www.peacefulseasangha.com/sampleforliz/files/CUT H.html">
<?
}
else {
print( "Error: Unknown error ocurred. The message could not be sent. Please try again later.\n");
}
?>
and here is the code from the html file:
"...
Contact FORM
</div>
<div id="cu">
Please use the form below to send us email. Thank You.
<div id="flabels">
<br>Name:
<br>Email:
<br>Comments:
</div>
<div id="fitems">
<br>
<form name="form1" method="post" action="mail_t.php">
<input type="text" name="user" size="25">
<input type="text" name="emailaddress" size="25">
<textarea cols="10" rows="4" name="comments"></textarea>
<input type="submit" value="Send">
</form>
</div> ..."


I use the exact same code on many sites but this new site it just doesnt work with it. Does anyone have any idea what could be the reason?
Thanks.
Sami
sambkk is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 09-17-2006, 04:31 PM   #2 (permalink)
Contributing Member
 
labrocca's Avatar
 
Join Date: 01-24-06
Location: Las Vegas
Posts: 268
iTrader: 1 / 100%
Latest Blog:
None

labrocca is just really nicelabrocca is just really nicelabrocca is just really nicelabrocca is just really nicelabrocca is just really nicelabrocca is just really nicelabrocca is just really nicelabrocca is just really nice
Send a message via AIM to labrocca Send a message via Skype™ to labrocca
Does other php work? Try posting a phpinfo();

It's a possibility that globals are off. Try the form with using $_post.
__________________
Political Debate- Join this site to have indepth politics discussion.
Pron Proxy - Free anonymous proxy browsing
labrocca is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-18-2006, 12:47 AM   #3 (permalink)
Junior Member
 
Join Date: 09-17-06
Posts: 13
iTrader: 0 / 0%
Latest Blog:
None

sambkk is liked by many
hi
thanks for the comments.
no idea really how post a phpinfo()
I am trying to finsd where the globals would be controlled in the cpanel.
Sami
sambkk is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-18-2006, 03:39 AM   #4 (permalink)
v7n Mentor
 
JamieJelly's Avatar
 
Join Date: 03-09-06
Location: London UK
Posts: 2,796
iTrader: 0 / 0%
JamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest order
phpinfo() is a function to determine the set up you have of php.

Simply create a new php file with the following in it:
Code:
<?php phpinfo(); ?>
upload it to your server then navigate to that page. For example, save the file as phpinfo.php, put it on your server then open www.yourdomain.com/phpinfo.php

If it comes up with a big table about all sorts of php settings then php is installed and working.

Come back to us after that!
__________________
Bank charges
JamieJelly is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-18-2006, 05:52 AM   #5 (permalink)
Junior Member
 
Join Date: 09-17-06
Posts: 13
iTrader: 0 / 0%
Latest Blog:
None

sambkk is liked by many
hi thanks jamie.
I'll give it a try.

Sami
sambkk is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-18-2006, 05:59 AM   #6 (permalink)
Junior Member
 
Join Date: 09-17-06
Posts: 13
iTrader: 0 / 0%
Latest Blog:
None

sambkk is liked by many
hi jamie
i did as you suggested, and it came up with a bunch or records.
you may view the file here if you think you want to, and if it could offer a solution.

http://www.peacefulseasangha.com/files/phpinfo.php


thanks

sami
sambkk is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-18-2006, 07:59 AM   #7 (permalink)
Inactive
 
Mrblogs's Avatar
 
Join Date: 03-29-06
Posts: 546
iTrader: 0 / 0%
Mrblogs is just really niceMrblogs is just really niceMrblogs is just really niceMrblogs is just really niceMrblogs is just really niceMrblogs is just really niceMrblogs is just really niceMrblogs is just really niceMrblogs is just really niceMrblogs is just really niceMrblogs is just really nice
Send a message via MSN to Mrblogs Send a message via Yahoo to Mrblogs
I think you may want to re-work your php file to not use global variables, but instead use $_POST, $_GET or such.

Using register_globals is very insecure (for instance, if you use a variable without first initialising it).
Mrblogs is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-18-2006, 09:13 AM   #8 (permalink)
Junior Member
 
Join Date: 09-17-06
Posts: 13
iTrader: 0 / 0%
Latest Blog:
None

sambkk is liked by many
Hi
thanks for the replies.
I have been trying to use the post methid, but seems like I dont quite have it. I tried this:


<?
$to = "$_POST['xxx@xxxxx.com']";
$subject = "$_POST['Email from website contact form']";
$boundary = uniqid("");
$headers = "$_POST['from']";
$body = "
Name :$user
Email :$emailaddress
Comment :$comments
";

if (mail($to, $subject, $body,$headers)) {
print( "Thank you for emailing us.Your file has been sent succesfully");
?>
<meta http-equiv=refresh content="1;URL=http://www.peacefulseasangha.com/files/CUTH.html">
<?
}
else {
print( "Error: Unknown error ocurred. The message could not be sent. Please try again later.\n");
}

?>

but seems like its not correct.Well it doenst work,so I expect I dont know the proper format to use that method.

Sami
sambkk is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-19-2006, 01:30 AM   #9 (permalink)
v7n Mentor
 
JamieJelly's Avatar
 
Join Date: 03-09-06
Location: London UK
Posts: 2,796
iTrader: 0 / 0%
JamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest order
I haven't tested this, but I just quickly wrote this for you, it should work, it is very simple:
Code:
<?php if(isset($_POST['submit'])) { // define variables $name = $_POST['name']; $email = $_POST['email']; $comment = $_POST['comment']; // you will want to add some validation in here // email headers $headers .= "From: From Name<mail@example.com>\n"; // change to whatever you want $headers .= "X-Sender: <mail@example.com>\n"; // change to whatever you want $headers .= "X-Mailer: PHP\n"; // mailer $headers .= "Return-Path: <mail@example.com>\n"; // Return path for errors $subject = "Subject Here"; $emailbody = " Name: $name Email: $email Comments: $comment "; if(mail("youremail@example.com", $subject, $emailbody, $headers, "-fbounce@example.com")) { $message = "<p>Your message was successfully sent</p>"; } else { $message = "<p>Sorry, your message could not be sent right now</p>"; } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title>Contact Form</title> </head> <body> <?php // display message if set if(isset($message)) { echo $message; } ?> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" accept-charset="utf-8"> <p> <label for="name">Name:</label> <input type="text" name="name" id="name" tabindex="1" /> </p> <p> <label for="email">Email:</label> <input type="text" name="email" id="email" tabindex="2" /> </p> <p> <label for="comment">Comments:</label> <textarea name="comment" id="comment" tabindex="3" rows="5" cols="10"></textarea> </p> <p> <input type="submit" name="submit" id="submit" value="Send!" /> </p> </form> </body> </html>
You may want to add some javascript validation in, and also some PHP validation too
__________________
Bank charges
JamieJelly is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-19-2006, 02:14 AM   #10 (permalink)
Inactive
 
jeet's Avatar
 
Join Date: 03-04-06
Posts: 181
iTrader: 0 / 0%
jeet is a jewel in the roughjeet is a jewel in the roughjeet is a jewel in the roughjeet is a jewel in the roughjeet is a jewel in the roughjeet is a jewel in the roughjeet is a jewel in the rough
Try this:

$mail_path = "/usr/sbin/sendmail -i -t";
ini_set("sendmail_path", $mail_path);

Put this somewhere on the very top of the php script.
I hope that works and solves your problem..

Secondly, go for cgi contact forms. Your php contact form script is too open for spam injection attacks. If a spammer finds it, you run a high risk of being accused for sending spam, even though you didn't send it, which may get your hosting account cancelled.
Bye
jeet is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-19-2006, 05:38 PM   #11 (permalink)
Junior Member
 
Join Date: 09-17-06
Posts: 13
iTrader: 0 / 0%
Latest Blog:
None

sambkk is liked by many
Thanks guys for the help
unfortunately I still havent found the solution.
I am probably not following instructions correctly or something.

I will look into the cgi forms if they are more secure.
I think we have enough spam already.

if I dinf a way I'll post it here, just for future reference, incase anyone alese goes through the same ordeal, but feel pretty hopless right now.

Sami
sambkk is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML contact form awg Coding Forum 14 07-30-2008 02:12 AM
Help me with a better contact form andreeam Coding Forum 4 11-18-2006 01:56 PM
HTML Contact Form help! kakarotto Coding Forum 4 03-30-2006 06:18 PM
Contact form script? I, Brian Coding Forum 6 01-14-2004 01:27 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 11:19 PM.
© Copyright 2008 V7 Inc