Jump to content

KashMoney

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

KashMoney's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you all for your help especially ~n[EO]n~ you have been really helpful. KashMoney
  2. I see what you are trying to do, but I want it to go to another page with just the text saying sent successfully. When i do not put anything on the form I want it to highlight like a box in red then when you put something in then it goes away on submit. Not to be annoying. Not what I wanted done. I mean the idea of the stuff showing on top of the form of the missing stuff but the highlights are gone and the next page saying mail successfully gone is not in the code that you put out. Please bare with me.
  3. The thing is though my validation doesn't display on exactly which form is missing like i had it before. It highlights it.
  4. Not sure what you mean on the code part?
  5. I am not trying to bump up my post but I did the part where when someone click submit it sents me an email but the thing is php doesn't do any validation when I leave something blank on the form field. Here is the part that I did; <?php if(isset($_POST['submit'])) { $to = "myemail@name.com"; $subject = "Submission Form"; $fname_field = $_POST['firstname']; $lname_field = $_POST['lastname']; $email_field = $_POST['email']; $web_field = $_POST['web']; $subject_field = $_POST['subject']; $message = $_POST['message']; $body = " First Name: $fname_field\n Last Name: $lname_field\n E-Mail Address: $email_field\n Website URL: $web_field\n Subject: $subject_field\n Message: $message\n"; echo "<center>The message was sent successfully!</center>"; mail($to, $subject, $body); } else { echo "<center>Error Try Again!</center>"; } ?> Any help would be appreciated! Thanks, KashMoney
  6. I simply left something out of the php side now it works! My mistake. Now just need help sending the data to my email and when someone clicks submit it says successfully sent. KashMoney
  7. I tried that and when i hit submit it doesn't display the email error!
  8. Hello, I have some issues with my php validation form. I need help with email field validation, Send the data to my email, and finally when submit have it say on the next page or even same page, Successfully sent. <? // Create an empty array to hold the error messages. $arrErrors = array(); //Only validate if the Submit button was clicked. if (!empty($_POST['Submit'])) { // Each time there?s an error, add an error message to the error array // using the field name as the key. if ($_POST['firstname']=='') $arrErrors['firstname'] = 'Please provide your first name.'; if ($_POST['lastname']=='') $arrErrors['lastname'] = 'Please provide your last name.'; if ($_POST['email']=='') $arrErrors['email'] = 'A valid email address is required.'; if ($_POST['subject']=='') $arrErrors['subject'] = 'Please enter a subject.'; if ($_POST['message']=='') $arrErrors['message'] = 'Please enter content in the message box.'; if (count($arrErrors) == 0) { // If the error array is empty, there were no errors. // Insert form processing here. } else { // The error array had something in it. There was an error. // Start adding error text to an error string. $strError = '<div class="formerror"><p>Please check the following and try again:</p><ol>'; // Get each error and add it to the error string // as a list item. foreach ($arrErrors as $error) { $strError .= "<li>$error</li>"; } $strError .= '</ol></div>'; } } ?> Form xhtml <fieldset id="emailform"> <p class="center"> If you want to contact me for anything regarding my site or any jobs that you need to be done. Please fill the form below and I will get back with you within 24 hours or less.</p> <?php echo $strError; ?> <form method="post" action="contact.html"> <!-- For every form field, we do the following... Check to see if there?s an error message for this form field. If there is, add the formerror class to the surrounding paragraph block. The formerror class contains the highlighted box. --> <p<?php if (!empty($arrErrors['firstname'])) echo ' class="formerrorl"'; ?>> <label for="firstname">* First Name:</label> <input name="firstname" type="text" id="firstname" size="30" value="<?php echo $_POST['firstname'] ?>"> </p> <p<?php if (!empty($arrErrors['lastname'])) echo ' class="formerrorl"'; ?>> <label for="lastname">* Last Name:</label> <input name="lastname" type="text" id="lastname" size="30" value="<?php echo $_POST['lastname'] ?>"> </p> <p<?php if (!empty($arrErrors['email'])) echo ' class="formerrorl"'; ?>> <label for="email">* Email Address:</label> <input name="email" type="text" id="email" size="30" value="<?php echo $_POST['email'] ?>"> </p> <p> <label>Website URL:</label> <input type="text" name="web" size="30" id="web" value="http://" /> </p> <p<?php if (!empty($arrErrors['subject'])) echo ' class="formerrorl"'; ?>> <label for="subject">* Subject:</label> <input name="subject" type="text" id="subject" size="30" value="<?php echo $_POST['subject'] ?>"> </p> <p<?php if (!empty($arrErrors['message'])) echo ' class="formerrorl"'; ?>> <label for="message">* Message:</label> <br /> <textarea rows="10" name="message" cols="85" id="message" value="<?php echo $_POST['message'] ?>"></textarea> </p> <p> <input type="submit" name="Submit" value="Submit"> <input type="reset" name="Reset" value="Reset"> </p> </form> <div class="italic">* required</div> </fieldset> Thanks in advance. KashMoney
  9. Well the error doesn't show up anymore which is a good thing but now the number is at 1 it does change after a refresh or when i go back and click on that page!
  10. I tried your method rajivgonsalves but its saying at three for some reason. So weird! At first when i reset my browser I get this mesage Warning: fread() [function.fread]: Length parameter must be greater than 0. in /home/mmaaaco/public_html/kkashou/homework/q3/counter.php on line 6 2. After I refresh again its goes back to 3. Hope this helps. Anything else? KashMoney
  11. Hello, I am trying to do a hit counter that writes an ip address to a text file. I only want ip's that are unique. This is what I have; <?php $filename = "hits.txt"; $file = file($filename); $file = array_unique($file); $hits = count($file); echo $hits; $fd = fopen ($filename , "r"); $fstring = fread ($fd , filesize ($filename)); fclose($fd); $fd = fopen ($filename , "w"); $fcounted = $fstring."\n".getenv("REMOTE_ADDR"); $fout= fwrite ($fd , $fcounted ); fclose($fd); ?> Then ovbiously the hits.txt logs all of the hit counter unique ip address. The problem I have with this script is that every time I reload the number says at 3 it does add +1 every time. Any Help on that? Thanks, KashMoney
  12. Thank you very much everyone for all of your help! KashMoney
  13. For some reason they are not working. But I am going for this code here; <? if (eregi('^[[:digit:]]{3}\-[[:digit:]]{0,2}\-[[:digit:]]{4}$', $_POST['socials'])) { echo 'Valid Social Security Format'; } else { echo 'Invalid Social Security Format'; } ?> <p>NOTE: Social secrity format is xxx-xx-xxxx</p> <form method="post" action="quiz.html" name="q1"> Social Securtiy <input type="text" name="socials" id="socials" /> <input type="submit" value="Submit" name="Submit" /> </form> Its just when i go to the page it already has the message "Invalid Social Security Format" I do not want that message to show when someone load on to the page! How can I fix that part? Thanks, KashMoney
  14. I put int the code that you did and I got an error Parse error: syntax error, unexpected '{' in /home/mmaaaco/public_html/kkashou/homework/quiz.html on line 16 This is my code with your code; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <?php if($_POST['submit'] && !(isset($message) || isset($error))) { //if the form is submitted check to see if all the data was filled out if($_POST['social']) { //if all og the data is filled out check to see if it is valid //format is xxx-xx-xxxx $social = $_POST['social']; if(ereg("([0-9]{3})-([0-9]{2})-([0-9]{4})", $social) { //if it is valid return that it is $message = 'Valid Social Security Format'; } else { //if it is not valid tell the user $error = 'Invalid Social Security Format'; } } else { $error = 'You must fill out all of the data'; } } elseif($_POST['submit'] && (isset($message) || isset($error))) { if(isset($message)) { print $message; } elseif(isset($error)) { print $error . '<br />'; print 'NOTE: Social secrity format is xxx-xx-xxxx'; print '<form action=' . $_SERVER['PHP_SELF'] . ' method=post>'; print '<label for=social>Social Security #: </label><input type=text name=social id=social value="' . $_POST['social'] . '" /><br />'; print '<input type=submit name=submit value=Submit />'; print '</form>'; } else { print 'An unknown error occured. Please notify the site admin.'; } } elseif(!$_POST['submit'] && !(isset($message) || isset($error))) { print 'NOTE: Social secrity format is xxx-xx-xxxx'; print '<form action=' . $_SERVER['PHP_SELF'] . ' method=post>'; print '<label for=social>Social Security #: </label><input type=text name=social id=social /><br />'; print '<input type=submit name=submit value=Submit />'; print '</form>'; } else { print 'An unknown error occured. Please notify the site admin.'; } ?> <form method="post" action="$PHP_SELF" > Social Securtiy <input type="text" name="social" id="social" /> <input type="submit" value="Submit" name="Submit" /> </form> </body> </html>
×
×
  • 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.