|
|||
|
Hi,
I'm new to Php, I understand basic coding things related to variable, loops, functions... more client side. I would like a contact or comments form onmy website http://multiskillz.tekcities.com The page where the form is is there http://multiskillz.tekcities.com/index99_comments.php or link comment on the left window. I have used the php code from this web site http://www.freecontactform.com/email_form.php I made a few changes since I don't want exactly the same thing: Below is the html (index99_comments.html) <div id="gate_A_resize3_comments"><p id="blackboard"></p> <form method="post" name="contact_form" action="contact-form-handler.php"> <br><br><br><br> Your Name: <input type="text" name="name"> <br><br><br><br> Email Address: <input type="text" name="email"> <br><br><br> Message: <textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea> <input type="submit" value="Submit"> <a href="email_form.php"></a> </form> </div> And below the php related php code (email_form.php) <?php if(isset($_POST['email'])) { //EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "pascal.baro@hotmail.com"; $email_subject = "Website"; function died($error) { // your error code can go here echo "We are sorry, but there were error(s) found in the submitted form. "; echo "These errors appear below. <br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors. <br /><br />"; die(); } if (!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['comments'])) { died('We are sorry, but a field is missing.'); } $name = $_POST['name']; $email = $_POST['email']; $comments = $_POST['comments']; $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg-match($email_exp, $email_from)) { $error_message .= 'The email address is not valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp, $name)) { $error_message .= 'The name does not seem valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The comments does not seem valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type", "bcc:", "to:", "cc:", "href"); return str_replace($bad, "",$string); } $email_message .= "Name: ".clean_string($name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; //create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n". 'X-Mailer: PHP/' .phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon. <?php } ?> I understand I have to change a few settings on the localhost server for this work locally (I'm using Windows 7 and Xamp). As I want to get quickly tothe point, I'm testing it directly online on http://multiskillz.tekcities.com/index99_comments.php and it just keeps failing. Do I have to change settings on the server as well (batcave or tekcities)? Or is it something about the code? Thanks if you can provide any clue or answer. Pascal |
|
|
||||
|
||||
|
|
|
|||
|
On 10-08-2012 21:49, bpascal123 wrote:
> Hi, > > I'm new to Php, I understand basic coding things related to variable, loops, functions... more client side. I would like a contact or comments form on my website http://multiskillz.tekcities.com > > The page where the form is is there http://multiskillz.tekcities.com/index99_comments.php or link comment on the left window. > > I have used the php code from this web site http://www.freecontactform.com/email_form.php > > I made a few changes since I don't want exactly the same thing: > > Below is the html (index99_comments.html) > > <div id="gate_A_resize3_comments"><p id="blackboard"></p> > > <form method="post" name="contact_form" action="contact-form-handler.php"> read above, when form is submitted, control goes to "contact-form-handler.php" and in next line the <a href.....</a> does not make much sence.... > <input type="submit" value="Submit"> <a href="email_form.php"></a> > </form> > > I understand I have to change a few settings on the localhost server for this work locally (I'm using Windows 7 and Xamp). As I want to get quickly to the point, I'm testing it directly online on http://multiskillz.tekcities.com/index99_comments.php and it just keeps failing. > yes, you DO need to learn HTML ![]() > Do I have to change settings on the server as well (batcave or tekcities)? > Or is it something about the code? > > Thanks if you can provide any clue or answer. > > Pascal > |
|
|||
|
Hi
I had quite a long day so my coding is weak and thus dealing with scripting languages I am not used to is indeed a challenge. Anyway, I spot the things you've mentioned and else. Now, I get to the page: "Thank you for contacting us. We will be in touch with you very soon." So, it means the script is working. However, I'm not receiving any messages...should I wait longer? Usually, hotmail is fast at delivering mail. Please advise Pascal |
|
|||
|
On 10-08-2012 23:42, bpascal123 wrote:
> Hi > I had quite a long day so my coding is weak and thus dealing with scripting languages I am not used to is indeed a challenge. > > Anyway, I spot the things you've mentioned and else. Now, I get to the page: > "Thank you for contacting us. We will be in touch with you very soon." So, it means the script is working. No, it means the last part of your code works, > However, I'm not receiving any messages...should I wait longer? Usually, hotmail is fast at delivering mail. you should check if hotmail received the message > > Please advise > Pascal In your code is a line that reads: @mail($email_to, $email_subject, $email_message, $headers); The '@' makes sure that you dont see any error messages that could be the result of the funciton 'mail'. Thahts why you do NOT know if the message is send, or not... |
|
|||
|
On 11/08/12 09:58, Luuk wrote:
> On 10-08-2012 23:42, bpascal123 wrote: >> Hi >> I had quite a long day so my coding is weak and thus dealing with scripting languages I am not used to is indeed a challenge. >> >> Anyway, I spot the things you've mentioned and else. Now, I get to the page: >> "Thank you for contacting us. We will be in touch with you very soon." So, it means the script is working. > > No, it means the last part of your code works, > >> However, I'm not receiving any messages...should I wait longer? Usually, hotmail is fast at delivering mail. > > you should check if hotmail received the message Keep in mind that hotmail (micorosft) spam filter is a pita, and they will not tell you if the mail was detected as spam, for then it will never get to your mailbox, only mail that they think may or may not be spam will end up in the junk mail folder. Usually mail without a proper mail header will be regarded as spam and never be delivered to the receiver. > In your code is a line that reads: > @mail($email_to, $email_subject, $email_message, $headers); > > The '@' makes sure that you dont see any error messages that could be > the result of the funciton 'mail'. > > Thahts why you do NOT know if the message is send, or not... mail() just returns true or false and even if you get a true result, you aren't guaranteed that mail will be sent, you will only know it had a successful connection to the SMTP/sendmail. -- //Aho |
|
|||
|
Thanks all,
This is working, I switched from hotmail to gmail... Very basic php, I wonder how much secured is it? Why are there some Php scripts that provide so much controls over what a user can enter (input)??? I would understand this if there is a database somewhere but for such a form... Thanks again, Pascal http://multiskillz.elementfx.com/index99_comments.html |
|
|||
|
In article <0c3f85a9-e29c-4edd-9c76-419ce2685bad@googlegroups.com>,
bpascal123 <bpascal123@gmail.com> wrote: > Thanks all, > This is working, I switched from hotmail to gmail... > Very basic php, I wonder how much secured is it? > Why are there some Php scripts that provide so much controls over what a user > can enter (input)??? I would understand this if there is a database somewhere > but for such a form... > Thanks again, > Pascal > http://multiskillz.elementfx.com/index99_comments.html I think you need to read up on php and how it works more throughly. It runs on a remote system (or the local system using a web server with php linked/added into it). The ability to enter data via the web is a function of the html <form> tag, not php. What you do with that data and how secure the environment is depends on the knowledge and skill of the php programmer. Injection attacks can be filtered out with the proper screening of data obtained from a form. There are lots of sites that discuss web site security. Google them to expand your understanding. php can run standalone as part of a web server with a database. Or it can be shared amongst other users with proper permissions or ACLs security access to the php source code running on the server. Again, this requires the implementor know enough about the security model of the environment he's running on. Google is your friend here also. So some more reading and ask your question again. -- DeeDee, don't press that button! DeeDee! NO! Dee... [I filter all Goggle Groups posts, so any reply may be automatically ignored] |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|