Jump to content

mattrd

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mattrd's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Okay, I found out that most of the emails were going to my junk mail filter. But some didn't. Also, most of the emails show up under the name "Unknown Sender" while others show the name that was put into the name field. Any idea what could be causing that?
  2. I can't seem to get my email form to work. yet it seems to work "sometimes" but not sure why, now i can't seem to get it to work at all. here is my code. <?php $title="Contact Me"; ?> <?php include("includes/header.php"); ?> <?php if ($_POST["email"]<>'') { $ToEmail = 'MY-EMAIL-GOES-HERE; $EmailSubject = 'Website Contact Form'; $mailheader = "From: ".$_POST["name"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["name"]."<br>"; $MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>"; $MESSAGE_BODY .= "Comment: ".nl2br($_POST["comments"])."<br>"; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); ?> <div id="content"> <h1>Contact.</h1> Your message was sent. <?php } else { echo "<div id=\"content\"> <h1>Contact.</h1> <p>Please use the form below to send me an email. I'd love to hear from you!</p> <form action=\"contact.php\" method=\"post\"> <label>Name:</label><br /> <input class=\"text\" type=\"text\" name=\"name\" /><br /> <label>Email Address:</label><br /> <input class=\"text\" type=\"text\" name=\"email\" /><br /> <label>Comments:</label><br /> <textarea name=\"comments\" cols=\"60\" rows=\"5\" name=\"comments\"></textarea> <br /> <input type=\"submit\" value=\"Submit\" /> </form>;" ?> </div> <?php }; ?> <?php include("includes/footer.php"); ?> Any help will be greatly appreciated. (form can be viewed here:) http://www.matthewrdaniels.com/contact.php Thank you!
  3. Sorry, I really don't know what to call this in the title. but this is what I want to do. I built an online journal which all the info is stored in a mysql database. On the homepage of my site, I have a small box which is a "teaser" that will always show only the beginning of the latest journal post. Let's say... the first 200 characters or something along those lines. How do I get the box to only show the first 200 characters of the journal post? I'm very new to php & mysql so I really have no clue how to start doing this on my own. I thought about displaying everything and just using css to set the overflow to hidden, but this isn't ideal. Any help or any guidance in pointing me in the right direction would be extremely appreciated. Thank you.
  4. neverming. I was stupid and didn't put the variable into the value attribute. thanks so much for the help!!
  5. thanks for the suggestions, but it doesn't seem to be working. ???
  6. I want to make my email input and password input sticky so if they fill out email but don't fill out password they don't both reset. I would assume that I should put the input value as value=\"if (isset($_POST['email'])) echo $_POST['email'];\" but this isn't working and I am getting an error what am I doing wrong? If anyone could help me I'd really appreciate it. thank you! here is all my code (without the values in the inputs) <div id="right_nav"> <div id="tip">Welcome to the Berks County Foster Parent Association Website</div> <div id="login"> <?php /* write a conditional to see if form was submitted */ if (isset($_POST['submitted'])) { if (!empty($_POST['email']) && !empty($_POST['password'])) { echo "<p class=\"center bold\">Welcome User!<br />\n You are currently logged in.</p><p class=\"center\">\n\n <a href=\"#\" style=\"left:0\">Logout</a></p></div>"; include("user_nav.php"); } else { echo "<ul>"; if (!empty($_POST['email'])) { $email = $_POST['email']; } else { $email = NULL; echo "<li>You didn't enter an email address!</li>"; } if (!empty($_POST['password'])) { $password = $_POST['password']; } else { $password = NULL; echo "<li>You didn't enter a password!</li>"; } echo "</ul>"; echo "<form action=\"index.php\" method=\"post\"> <p><span>Email Address:</span><br /><input class=\"login_input\" type=\"text\" name=\"email\" /></p> <p><span>Password:</span><br /><input class=\"login_input\" type=\"password\" name=\"password\" /></p> <p><input id=\"login_button\" type=\"submit\" name=\"submit\" value=\"Login\" /><a href=\"#\">forgot password</a></p> <input type=\"hidden\" name=\"submitted\" value=\"TRUE\" /> </form></div>"; include("general_nav.php"); } } else { echo "<form action=\"index.php\" method=\"post\"> <p><span>Email Address:</span><br /><input class=\"login_input\" type=\"text\" name=\"email\" /></p> <p><span>Password:</span><br /><input class=\"login_input\" type=\"password\" name=\"password\" /></p> <p><input id=\"login_button\" type=\"submit\" name=\"submit\" value=\"Login\" /><a href=\"#\">forgot password</a></p> <input type=\"hidden\" name=\"submitted\" value=\"TRUE\" /> </form></div>"; include("general_nav.php"); } ?> </div>
  7. holy crap. DUH! So simple. Thank you so so much!!
  8. I have a form that will refresh once it is submitted. There are two fields that if left blank will cause an error message and display the form again. If they submit the form correctly it will refresh the page and display a thank you message. But the form displays again. I don't want the form to display if they filled it out correctly. I don't know how to do this. I have an include_once that displays the form now. this is just because if I don't have it it won't show up at all. This is my code, can anyone please help me? thank you. <?php # Define the page title $page_title = 'Post to Journal'; # Include header and navigation menu include('includes/header.php'); include('includes/left_nav_admin.php'); include('includes/greenbox.php'); # Define necessary variables $months = array(1 => 'January','February','March','April','May','June','July','August','September','October','November','December'); $day = 1; $year = 2008; ?> <h2>Post a Journal Entry</h2> <div id="right"> <?php # If statement that detects if the form as been submitted. if (isset($_POST['submitted'])) { # Write out a thank you message if form was filled out correctly. If not, write out an error message. if (!empty($_POST['title']) && ($_POST['entry'])) { echo "<p class=\"green bold\" style=\"margin-bottom:10px;\">Thank you. Your entry has been posted.</p>"; } else { echo "<p class=\"red bold\">Your entry has the following errors!</p>"; # Write out an error message if title is empty. echo "<ul id=\"error_list\">"; if (!empty($_POST['title'])) { $title = $_POST['title']; } else { $title = NULL; echo "<li>You didn't enter a title!</li>"; } # Write out an error message if the content is empty. if (!empty($_POST['entry'])) { $title = $_POST['title']; } else { $title = NULL; echo "<li>You didn't make an entry!</li>"; } echo "</ul>"; include_once('journal_entry_form.php'); } } # Include the form include_once('journal_entry_form.php'); ?> </div> </div> <!-- include the footer //--> <?php include('includes/footer.php'); ?> </body> </html> The page can be seen here: http://www.matthewandchris.com/test.php
  9. tried using mjdamato's code and it spit out an error Fatal error: Can't use function return value in write context in /home/mattrd/public_html/php/form_validation2.php on line 11 can anyone help?
  10. sorry about not posting code, here is the php code: <?php if (isset($_POST['submitted'])) { #define variables for the mad lib and write out an error message if any fields in the form were left blank #disable magic quotes using the stripslashes function #remove left and right spaces if they are entered in the form using the trim function. if (!empty($_POST['1'])) { $one = trim(stripslashes($_POST['1'])); } else { $one = NULL; echo "<span style=\"color:#ff0000;\">You didn't enter a plural noun!</span><br />"; } if (!empty($_POST['2'])) { $two = trim(stripslashes($_POST['2'])); } else { $two = NULL; echo "<span style=\"color:#ff0000;\">You didn't enter an adjective!</span><br />"; } if (!empty($_POST['3'])) { $three = trim(stripslashes($_POST['3'])); } else { $three = NULL; echo "<span style=\"color:#ff0000;\">You didn't enter the first noun!</span><br />"; } if (!empty($_POST['4'])) { $four = trim(stripslashes($_POST['4'])); } else { $four = NULL; echo "<span style=\"color:#ff0000;\">You didn't enter the second noun!</span><br />"; } if (!empty($_POST['5'])) { $five = trim(stripslashes($_POST['5'])); } else { $five = NULL; echo "<span style=\"color:#ff0000;\">You didn't enter the third noun!</span><br />"; } #place the mad lib inside of a variable #include and concatenate the previous defined variables $madlib = "Cinderella had two step-" . $one .", who were very " . $two . " to her. So her fairy god" . $three . " turned her pumpkin into a big " . $four . ", and dragged her off to the " . $five . "."; #write an if statement to display the madlib if filled out correctly, but display an error message if any fields in the form were left blank. if (($one == NULL) || ($two == NULL) || ($three == NULL) || ($four == NULL) || ($five == NULL)) { echo "<p style=\"color:#ff0000;\">Please fill out the form completely.</p>"; } else { echo $madlib; } #print out a custom paragraph after the mad lib but do not print anything if one or more of the fields in the form were left blank. if (($one == NULL) || ($two == NULL) || ($three == NULL) || ($four == NULL) || ($five == NULL)) { echo NULL; } else { if (($one == "watermelons") && ($two == "smelly") && ($three == "toilet") && ($four == "fanny") && ($five == "poop")) { echo "<p><em>\"Hey! You copied off me!! And now, I shall kill you!!\"</em></p>"; } elseif (($one == "watermelons") || ($two == "smelly") || ($three == "toilet") || ($four == "fanny") || ($five == "poop")) { echo "<p><em>\"Still using some of my words... get your own!!\"</em></p>"; } elseif (($one == "sisters") && (($two == "mean") || ($two == "evil") || ($two == "nasty")) && ($three == "mother") && ($four == "carriage") && (($five == "ball") || ($five == "castle"))) { echo "<p><em>\"Oh, you did it the way it's supposed to go... that's not very funny now is it?\"</em></p>"; } else { echo "<p><em>\"Haha! Oh, how ruthlessly absurd.\"</em></p>"; } } } else { echo "<p>Stewie's Mad Lib</p> <p>Do the same Cinderella Mad Lib that Stewie did in Family Guy! The text boxes are already filled in with the words he used on the show, but you can change them to your own words if you like. Have fun!</p> <form action=\"form_validation3.php\" method = \"post\"> <table border=\"0\"> <tr><td>Enter a plural noun</td><td><input name=\"1\" type=\"text\" value=\"watermelons\" /></td></tr> <tr><td>Enter an adjective</td><td><input name=\"2\" type=\"text\" value=\"smelly\" /></td></tr> <tr><td>Enter a noun</td><td><input name=\"3\" type=\"text\" value=\"toilet\" /></td></tr> <tr><td>Enter another noun</td><td><input name=\"4\" type=\"text\" value=\"fanny\" /></td></tr> <tr><td>Enter another noun</td><td><input name=\"5\" type=\"text\" value=\"poop\" /></td></tr> <tr colspan=\"2\"><td><input type=\"submit\" value=\"Let's see my Mad Lib!\" /></td></tr> <input type=\"hidden\" name=\"submitted\" value=\"TRUE\" /> </table> </form>"; } if (isset($_POST['submitted'])) { echo "<a href=\"form_validation3.php\">go back</a>"; } ?>
  11. I have a form, that when filled out, generates a mad lib followed by a custom paragraph based on how you filled out the form. I want the form to have preset values. This is all works fine, but if I change the preset value and then generate the madlib the page reloads with the preset values there again. How can I have preset values, yet make the form retain the custom answers I plug in after I generate the madlib? you can see the page here: http://matthewrdaniels.com/php/form_validation2.php I'm still very new to php. Any help would be greatly appreciated. Thank you!
×
×
  • 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.