Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Restrictions On Php & Forms?, $_GET/POST/REQUEST?
anachro
post Feb 18 2008, 08:57 AM
Post #1


Member [Level 1]
****

Group: Members
Posts: 68
Joined: 7-January 08
Member No.: 55,865



alright, so heres me again (theres probably a contact page on the website but I figure somebody has/will have this question and they'll want to know it so why not ask and share the love & knowladge (minus the love))

so I've been working on a two part contact page.

contact.php
CODE
<p><img src="images/sig.gif" align="left" width="37" height="69" style="margin-right: 5px;" alt="B/S Signature"/> <font
  class="head">Contact!</font><br/>

<form action="?page=mailer" method="post">
    <strong>*Name:</strong><br>
<input type="text" name="name" size="20">
<br>
    <strong>*E-mail Address:</strong><br>
<input type="text" name="email" size="45">
<br>
<strong>E-mail Subject:</strong><br>
<select type="subject" name="subject" value="subject" width="350"><br />
<option value=""></option>
<option value="Information Request">Information Request</option>
<option value="Quote Request">Quote Request</option>
</select><br><br />
<input name="human" type="checkbox" value="yes">
    Check if you are Human.*<br />
    (This is for your security)<br /><br />
    <strong>*Message/Comments:</strong><br>
<textarea rows="9" name="message" cols="30"></textarea>
<br>
<br>
<input type="submit" value="Submit" name="submit">
</form>
<br /><br />fields denoted with * are required.<br /><br />Your information will not be sold/given/other means of forwarding to anyone!</font>


Mailer.php
CODE
<?php
// where the mail will be sent
$to = "EMAILADDRESSREMOVED";
//whos recieving this message
$subject = $_REQUEST["subject"];
//Subject of the message
$name_field = $_REQUEST["name"];
//senders name (if provided)
$email_field = $_REQUEST["email"];
//senders email
$message = $_REQUEST["message"];
//senders message
$human = $_REQUEST["human"];
//Sets what the answer to the first filter will be (kind-of)=
//this is for the check box, makes it required, and echos a reminder if forgotten
if($human =="") { echo "You forgot to check the human box or are a spambot! <br /><a class='bodylink' href='java script:history.go(-1)'>click here to return to the previous page</a>.<br /><br />"; die;};

//makes sure that the senders name isn't blank
if($name_field=="") { echo "You forgot to fill out your name in the proper field!<br /><br /><a class='bodylink' href='java script:history.go(-1)'>click here to return to the previous page</a>.<br /><br />"; die;};

//makes sure that the senders name isn't blank
if($email_field=="") { echo "You forgot to fill out your Email Address in the proper field!<br /><br /><a class='bodylink' href='java script:history.go(-1)'>click here to return to the previous page</a>.<br /><br />"; die;};

//makes sure that the senders name isn't blank
if($message=="") { echo "You forgot to fill out any message/question(s)/or comment(s) in the proper field!<br /><br /><a class='bodylink' href='java script:history.go(-1)'>click here to return to the previous page</a>.<br /><br />"; die;};

//Once they click submit and it passes the required checks it gets sent
if(isset($_POST['submit'])) {

//subject and body fields
$headers  = "From: $email_field\n";
$body = " From: $name_field\n E-Mail: $email_field\n Subject: $subject\n Message:\n $message";
//sent message

//A little thanks, echo'd after
echo "<br />Thank you for your interest, you information has been sent,<br /><a class='bodylink' href='java script:history.go(-1)'>click here to return to the previous page</a>.<br />";
mail($to, $subject, $body, $headers);
//sends the email

} else {

echo "<br />Something was missing, please try again.<br /><a class='bodylink' href='java script:history.go(-1)'>click here to return to the previous page</a>.<br />";
// If something was wrong it tells them so, and then lets them go back and fix it
}
?>


and with the both of them primitive version have worked on other hosts, and I;ve been trying to outfit my codes to be more precise, or efficient (hopefully both) so I can FINALLY post my website in the review w/ pride. so, if you see anything that needs to be fixed in my scripts go ahead and tell me, and PLEASE tell me what I need to do to get this to work!!!
Go to the top of the page
 
+Quote Post
shadowx
post Feb 18 2008, 10:33 AM
Post #2


A clever man learns from his own mistakes, a WISE man learns from those of OTHERS
*********

Group: [HOSTED]
Posts: 884
Joined: 12-April 06
From: Essex, UK
Member No.: 21,719



Have you tried changing $_REQUEST to $_POST as you are using post variables. It may or may not work but its worth a go i guess.

Do you get any error messages? If so what are they?
Go to the top of the page
 
+Quote Post
galexcd
post Feb 18 2008, 09:52 PM
Post #3


Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software.
*********

Group: [HOSTED]
Posts: 975
Joined: 25-September 05
From: The dungeon deep below the foundation of trap17
Member No.: 12,251



QUOTE(shadowx @ Feb 18 2008, 02:33 AM) *
Have you tried changing $_REQUEST to $_POST as you are using post variables. It may or may not work but its worth a go i guess.

Do you get any error messages? If so what are they?


It might be best to do this so people couldn't just fill that information in the url, but request cant get everything that post can. It just matters if you want to restrict the get variable as well.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. **** Read Before You Post! ****(47)
  2. Halo 2 Glitches(48)
  3. *** Click Here To Get Your Free Hosting ***(1)
  4. The Most Annoying Website(57)
  5. Where In The World Are You From?(81)
  6. Get Paid To Post On Forums?(17)
  7. How To Get New Ip Address(12)
  8. What Movies Are You Waiting For(33)
  9. Integrity Checks Failing During Multiple Ajax Request(1)
  10. Post Your Favorite Easy To Make Meal.(16)
  11. Post Some Wierd Experiences At Night You've Had In Here.(2)
  12. Trap17 Dynamic Recent Post/topic Image(17)
  13. Free Web Hosting Request [screened] [approved](2)
  14. Sig Request- .:piper_2051:. [denied](1)
  15. Sig Request(3)
  1. My Hosting Request Email... [resolved](3)
  2. My Free Hosting Account Request(3)
  3. Why Has Everyone Ignored My Free Hosting Request?(7)
  4. How To Make A View New Post Script?(5)
  5. Free Web Hosting Account Request [denied](1)
  6. Free Web Hosting Application [screened] [approved](6)
  7. Post Your Banners Here(3)
  8. My Thoughts On Few Browsers(2)
  9. Free Web Hosting Request [denied](1)
  10. [request] Gimp Tutorial For Watermarking Pictures(2)
  11. Trap17's 400000th Post Giveaway!(12)
  12. Sig Request! [denied](1)
  13. Sig Request(1)


 



- Lo-Fi Version Time is now: 27th July 2008 - 02:22 AM