Jump to content

JaymeNYC

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

JaymeNYC's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm not able to send private messages, do you have aim?
  2. <?php session_start(); // this works well with redux - ie. form action = $_SERVER['PHP_SELF'] if(isset($_POST['submit'])) { // set a function that will clean your data function clean($value) { $var = strip_tags($value); $var = trim($value); return $var; } // still clean all data that is on the form $name = clean($_POST['name']); $email = clean($_POST['email']); $txt = clean($_POST['txt']); // check to see if field has been filled in at all // this is the spot to place the *manditory fields* // to validate that data has been entered. // If you don't require it as a manditory field then get rid of it. $_SESSION['error'] = NULL; if (empty($name)) { $_SESSION['error'] .= "You forgot to enter your name!<br />"; $name = FALSE; } if (empty($email)) { $_SESSION['error'] .= "You forgot to enter your email!<br />"; $e = FALSE; } // if all is true then send the email if ($name && $email) { $to = "Contact@enwisedesign.com.com"; $subject = "Company Form Filled"; $body = " Name: $name\n\n Email: $email\n\n Body: $txt"; $sent = mail($to, $subject, $body); if ($sent) { header ("Location: http://www.site.com/36/thankyou.php"); } // end if $sent } // end if all var are true if (empty($name)) { $_SESSION['error'] .= "You forgot to enter your name!<br />"; $name = FALSE; } if (empty($email)) { $_SESSION['error'] .= "You forgot to enter your email!<br />"; $e = FALSE; } } // end if post submit else { ini_set('error_reporting',E_ALL); // error reporting } ?> Ahh I'm tired. I have alot more I have to have done by the morning and would just rather have some1 do this lil part so is 15$ enough for 2 PHP cross-browser valid forms? Required field errors reporting to a div ("Name field Required.") email field must have @ (whatever email validation requires) Completed form sends to email Field color change if not completed properly Random answerable question (Captcha?) Thank you message appearing after form is validated/sent Anyone Interested? Just tired of lookin at code Paypal of course :D :D
  3. Where do I put it though? I'm REALLY new to php I was gettin help with this but haven't been able to lately so I'm lookin for help here. I did come across this page http://mobygreen.com/contact/#usermessageb which has the fields light up if they were not filled out correctly. Is this a whole different type of form? Also, where can I find some basic->intermediate php tutorials so I can learn faster? I feel handicapped.
  4. A little confused, mostly with the changing of $email to $e. What does that do? I'm very new to php so sorry if I don't pickup on the easy stuff!
  5. I'm still pretty new to PHP, and been gettin some help on my PHP form but I can't get past this one part, so don't know what to do! I'm trying to create a valid form that has 2 fields that are required, "Name, Email" and 1 field that is not and thats "Comments". Am I doin this the right way? <div id="contactform"><?php if (isset($_SESSION['error'])) { echo $_SESSION['error']; unset($_SESSION['error']); // this will reset the $_SESSION['error'] container } ?> <form method="post" action="thanks.php"> <div class="grp"><label for="name">Your Name</label><br /> <input class="" id="name" type="text" name="name" onfocus="this.style.backgroundColor='#f7ffe3' " onblur="this.style.backgroundColor='#fff'" /></div> <div class="grp"><label for="email">Your Email</label><br /> <input class="" id="email" type="text" name="email" onfocus="this.style.backgroundColor='#f7ffe3' " onblur="this.style.backgroundColor='#fff'" /></div> <div class="grp"><label for="txt">Your Message</label><br /> <textarea id="txt" name="txt" rows="" cols="" onfocus="this.style.backgroundColor='#f7ffe3' " onblur="this.style.backgroundColor='#fff'" ></textarea></div> <div class="grp2"><input class="formsubmit" type="submit" value="Submit" name="submit" /></div> </form> </div> Above is the contact form from the contact.php form page. It said I was missing somethin in the php file so my whole contact page wouldnt load and i saw that the unset didnt have a ")" on the end so it looked like this before I added unset($_SESSION['error']; thanks.php is below <?php session_start(); // this works well with redux - ie. form action = $_SERVER['PHP_SELF'] if(isset($_POST['submit'])) { // set a function that will clean your data function clean($value) { $var = strip_tags($value); $var = trim($value); return $var; } // still clean all data that is on the form $name = clean($_POST['name']); $email = clean($_POST['email']); $txt = clean($_POST['txt']); // check to see if field has been filled in at all // this is the spot to place the *manditory fields* // to validate that data has been entered. // If you don't require it as a manditory field then get rid of it. $_SESSION['error'] = NULL; if (empty($name)) { $_SESSION['error'] .= "You forgot to enter your name!<br />"; $name = FALSE; } if (empty($email)) { $_SESSION['error'] .= "You forgot to enter your email!<br />"; $e = FALSE; } // if all is true then send the email if ($name && $email) { $to = "email@gmail.com"; $subject = "Company Form Filled"; $body = " Name: $name\n\n Email: $email\n\n Body: $txt"; $sent = mail($to, $subject, $body); if ($sent) { header ("Location: http://www.website.com/thankyou.php"); } // end if $sent } // end if all var are true } // end if post submit // then within your form page where you want // the error message to display, have the following code: ?> When I hit the submit button and I leave a field blank, it goes to a blank page. Is how I did this right so far? Whats the best way to report errors? I would like to use this on my other sites but don't know if I'm coding this the right way to use it over and over again. Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.