PHP contact form

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Ru
-


Joined: 10 Apr 2007
Posts: 10

PostPosted: Sat Jun 02, 2007 3:45 pm    Post subject: PHP contact form Reply with quote

Hello to all, im sorry if repeat someone with this thread. I did seacrh and didnt found a solution of my problem:
I have a contact form with 3 textareas:
1-NAME
2-E-MAIL
3-COMMENTS

And whats happend in test. If i fill everything correct in this 3 areas the script telling me that i didnt fill the Name field, which i did filled
This is on home pc with abyss on it, php suport added and so on the script working but not at all as u see.When i upload the form in a free server with php suport theres no problem averything work fine, so i dont have any clue where im wrong. I did setup my php environment as it described at the abyss thread for this.

Thats the code i use in php file

Quote:
<?php
$name = $HTTP_POST_VARS['name'];
$email = $HTTP_POST_VARS['email'];
$comments = $HTTP_POST_VARS['comments'];
if (strlen($name) == 0)
{
echo "It appears that you have forgot to fill in your name in the Name field. Please use the Back Button to return to the form and enter your name. Thank you!";
exit;
}
if (strlen($name) >=25)
{
echo "The length limit for the Name field cannot exceed 25 characters / spaces. Please use the Back Button to return to the form and shorten this entry. Thank you!";
exit;
}
if (strlen($email) == 0)
{
echo "The E-mail field is a required entry. Please use the Back Button to return to the form and enter a contact E-mail address. Thank you!";
exit;
}
if (strlen($email) >= 25)
{
echo "The length limit for the E-Mail field cannot exceed 25 characters / spaces. Please use the Back Button to return to the form and shorten this entry. Thank you!";
exit;
}
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
echo "I believe that there is an error in the way you entered your E-mail address. Please check your entry and re-submit. Thank you!";
exit;
}
if (strlen($comments) >= 300)
{
echo "The comments area is limited to 300 characters / spaces. It appears that you have exceeded that limit. Please use the back button to return to the form and shorten this entry.Thank you!";
exit;
}
if (substr_count($comments , '@') > "2")
{
echo "For security reasons this text (comments) area limits the number of @ symbols that can appear within it. It would appear that you have exceeded that number. Please use the Back Button to return to the form and correct this. Thank you for your patience!";
exit;
}
//SEND MAIL
$mailto = "incomin@mypage.com";
$mailsubj = "Submisions From verysoon.info";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values Submitted From VERYSOON.INFO Form:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
$mailbody .= "$key : $val\n";
}
mail($mailto,$mailsubj,$mailbody,$mailhead);
echo "Thank you for visiting our site and filling out our form. We will get back to you very soon!";
?>


Thats the code of the contact page, where the form is

Quote:
<form name="bp_c_us" method="POST" action="thanks.php" enctype="multipart/form-data">
<input type="text" id="Editbox1" style="position:absolute;left:92px;top:21px;width:198px;border:1px #C09F23 solid;background-color:#B9BCC1;font-family:Tahoma;font-size:11px;z-index:0" size="39" name="name" value="" maxlength="25">
<input type="text" id="Editbox2" style="position:absolute;left:92px;top:51px;width:198px;border:1px #C09F23 solid;background-color:#B9BCC1;font-family:Tahoma;font-size:11px;z-index:1" size="39" name="email" value="" maxlength="25">
<textarea name="comments" id="TextArea1" style="position:absolute;left:92px;top:81px;width:313px;height:80px;border:1px #C09F23 solid;background-color:#B9BCC1;font-family:Tahoma;font-size:11px;z-index:2" rows="5" cols="58">You can put your inquiries too.</textarea>

I think theres a problem in abyss i mean the setup of the php, but dont have a clue, anyone can help.
Thank u
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Sat Jun 02, 2007 5:01 pm    Post subject: Reply with quote

Are you running a mail server?
or
Have you set the smtp server in the php.ini to point to a mail relayer?

If you say no to both of those then there is your problem :-)

Also what is the error you get when running it on Abyss?
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
Ru
-


Joined: 10 Apr 2007
Posts: 10

PostPosted: Sat Jun 02, 2007 5:23 pm    Post subject: Reply with quote

I dont have a mail server on this machine, but i did set up the smtp.server in the php.ini.
The point is that theres no error due sending process couse i cant reach to the sending process, simply my form tells me that im not filled the "Name" filed in the form but i actually i typed my name there. (just the form is coded with security issues and non blank fields)
Ive upload the same files on a free server with php support and SMTP is OFF and the form works good without any errors, no matter that im no recieving anything couse of SMTP off.
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Sat Jun 02, 2007 5:27 pm    Post subject: Reply with quote

$name = $HTTP_POST_VARS['name'];

change this to

$name = $_POST['name'];

and do the same for the others, then try again. This is what I use on my forms.

You may also have to include an

if($_POST){

script

}

around your script.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
rrinc
-


Joined: 24 Feb 2006
Posts: 725
Location: Arkansas, USA

PostPosted: Sat Jun 02, 2007 8:45 pm    Post subject: Reply with quote

And for your check if the email field length is 0, I'd raise it from 0 to 6. Because it takes at least 7 characters to possibly be valid. The shortest an email address could possibly be is x@x.xx (7 characters).

Also, why limit the email address to 25 characters? I know of more than 2 email addresses that exceed 25 charcters.
_________________
-Blake | New Server :D
SaveTheInternet
Soy hispanohablante. Puedes contactarme por mensajes privados.
Back to top View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Ru
-


Joined: 10 Apr 2007
Posts: 10

PostPosted: Sat Jun 02, 2007 11:03 pm    Post subject: Reply with quote

Hmm actualy i did what AbyssUnderground said and it worked but i didnt paste
if($_POST){

script

}
Now the form seems to be okay with the code, have some smtp issues and havent check it 100%

rrinc i just set this values for the test, ill modify them after i make full test of the form.
ill write back if something wrong popup
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group