Jump to content

Form for Contact Me


Guest recan1230

Recommended Posts

Guest recan1230

;) Hello Fellow Members,

I am trying to add a contact form on my contact me page on my website (http://www.designerwebgraphics.com), exactly like the example at this website http://www.osticket.com/contact.php. The form is very simple and I like it for my website. To my understanding their has to be an action code I have to add in order to receive it at my email. Could someone help me? I would greatly appreciate any feedback. Recan1230

Link to comment
Share on other sites

Guest garysmith

Your will have to create a html form on your contact us page and then pass the variable to a php script to process, format and sent the message to you as an email.

I have written a script for this that you can use as an example.

<?php

$name = $_REQUEST['name'] ;

$company = $_REQUEST['company'] ;

$email = $_REQUEST['email'] ;

$adcontent = $_REQUEST['message'] ;

$message2 =

"Message from: $name \n

Company: $company \n

Email Address: $email \n

message: \n $message" ;

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

{header( "Location: online.htm" );}

elseif (empty($name) ||empty($email) || empty($message)) {

?>

<html>

<head><title>Error</title></head>

<body>

<h1>Error</h1>

<p>

You have not completed all of the required fields. Please press the BACK button on your browser to try again.

</p>

</body>

</html>

<?}

else {

mail( "Youremail.co.uk", "Message from website",

$message2, "From: $email" );

header( "Location: thanks.htm" );

}

?>

The first 4 lines under the <?PHP collect the data from your form

$name = $_REQUEST['name'] ; the 'name' bit is what you would have called the text field for name in your form etc.

The second part puts all of the bits of information together as one string (the /n are line breaks) this is basically formatting how your email will look when it is received.

the rest of it checks that the field are filled out and if not sends then a message to fill required fields.

{header( "Location: online.htm" );} is where you have your form

If the script gets to the else statement then the email is sent, header( "Location: thanks.htm" ); is the page you will return them to after the message is sent, normally a thanks for sending the message type page.

Save as a PHP file with a title like message.php and in the form you created will be 'Action' that is where you call this script.

Sorry for the hasty explianation but the Mrs is waiting to go shopping if you cannot figure it all out you can post or pm me.

Gary

Link to comment
Share on other sites

Guest EverythingWeb

I hate to say it, as you have obvoiusly spent a little while putting that together, but it is *highly* insecure.

Give me 10mins and a cleverly crafted form request and your server will be acting as a nice open spam realy, capable of sending hundreds & hundreds of emails. Ack!

Think you really need to add even some very basic sanitisation of the variables etc.

Link to comment
Share on other sites

Guest EverythingWeb

I didn't mean to come across condescending or arrogant in any way at all.

I spend my life keeping servers secure and scripts like the one above are the bain of my life. LOL.

I was purely pointing out if someone used it verbatim from here then they are likely to hit problems.

I will probably work on a 99.9% secure script for a Contact Form using all the available security methods and release it out for people to use it. Hopefully that will help everyone out :)

Link to comment
Share on other sites

All ready have one with secure image validation and testing it :)

I might release it later, we shall see :)

Have posted in the .org forum about it but you can click my banner to see it in action ;)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...