Jump to content

JoeAM

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Everything posted by JoeAM

  1. Thank you so much, Muddy_Funster. That's EXACTLY what I was trying to accomplish. You've really helped me out here. Really appreciate it. I've been trying to figure this out for days.
  2. I know that isset() will probably come into play here but I just can't figure out where it needs to go. If i condense both pages into one and have the form call itself, I know that I can use isset() there. But this is the longest code I've written and I keep getting lost in the myriad if/then statements I've written. Thanks for the tip, but I'm trying to do this with just php and html. I haven't even started looking into javascript yet. But you're saying that what I'm looking to do is technically not possible if I don't use JS?
  3. Is it possible to prevent a form from processing if required fields aren't filled out on the HTML portion of the script? In other words, I have an .html file that displays the form and a .php file that displays some results as well as sends an email detailing the results. However, I'd like to STOP the form from ever getting to the .php page if certain fields (name, email, phone number) aren't entered into the form on the .html side. Is that do-able? Thank you very much for looking at this. <form action="accumen_request_handle.php" method="post"> <b>Describe the largest object which needs to be moved (in inches).</b> <br /><br /> Height? <input type = "text" name="height" type="text" size="2" maxlength="6" /> inches<p> Length? <input type ="text" name="length" type="text" size="2" maxlength="6" /> inches<p> Width? <input type ="text" name="width" type="text" size="2" maxlength="6" /> inches<p> <br /> Client Name: <input type ="text" name="client_name" type="text" size="25" /><p></p> Phone Number: <input type ="text" name="client_phone" type="text" size="25" maxlength="10" /><p></p> E-mail Address: <input type ="text" name="client_email" type="text" size="25" /><p></p> <input type="submit" name="submit" value="Submit Your Request" /> </form> <?php //set variables from form $height = $_POST["height"]; $width = $_POST ["width"]; $length = $_POST["length"]; $name = $_POST["client_name"]; $number = $_POST["client_phone"]; $email = $_POST["client_email"]; $strip_height = strip_tags($_POST['height']); $strip_width = strip_tags($_POST['width']); $strip_length = strip_tags($_POST['length']); $strip_client_name = strip_tags($_POST['client_name']); $strip_client_phone = strip_tags($_POST['client_phone']); $strip_client_email = strip_tags($_POST['client_email']); $total_height = 90; $total_width = 91; $total_length = 192; if (($strip_height <= $total_height) and ($height) > 0 ){ //if height is less than total height print("This will fit height-wise."); } elseif($strip_height >= $total_height) { //if height is more than total height print("Sorry, but this won't fit because it's too tall."); } if (($strip_width <= $total_width) and ($width) > 0) { //if width is less than total width print ("This will fit width-wise."); } elseif($strip_width >= $total_width) { //if width is more than total width print("Sorry, but this won't fit because it's too wide."); } if (($strip_length <= $total_length) and ($length) > 0) { //if length is less than total length print("This will fit length wise."); } elseif($strip_length >= $total_length) { //if length is more than total length print("Sorry, but this won't fit because it's too long."); } //height? if (empty($_POST['height'])) { print '<p class="error">Please enter a height.</p>'; $okay = FALSE; } //width if (empty($_POST['width'])) { print '<p class="error">Please enter a width.</p>'; $okay = FALSE; } //length? if (empty($_POST['length'])) { print '<p class="error">Please enter a length.</p>'; $okay = FALSE; } //client name? if (empty($_POST['client_name'])) { print '<p class="error">Please enter your name.</p>'; $okay = FALSE; } //phone number? if (empty($_POST['client_phone'])) { print '<p class="error">Please enter your phone number.</p>'; $okay = FALSE; } //email address? if (empty($_POST['client_email'])) { print '<p class="error">Please enter your email address.</p>'; $okay = FALSE; } ?> <?php $to = "[email protected]"; $subject = "Web Order Received"; //$body = "An order from the web site has been submitted.\n"; $content ="Height is $strip_height inches.\n Length is $strip_length inches.\n Width is $strip_width inches.\n Client Name is $strip_client_name.\n Client Email is $strip_client_email.\n Client phone number is $strip_client_phone"; if (mail($to, $subject,$content)) { print("<p>Your order has been successfully sent! We'll be contacting you shortly.</p>"); } else { print("<p>Your order has not been successfully sent!</p>"); } ?> <br /> <br /> <?php //print current date and time: //set the time zone: date_default_timezone_set('America/New_York'); //now print the date and time: print date('g:i a l F j'); print " EST" ?>
  4. Thanks for the tips. I agree that two pages seems to be the way to go. It seems like there should be a way to stop the form from processing if it's missing key data (the name,email, and phone, for instance) but I've yet to find a way to do that. Some other pieces of code I've tried haven't worked because as soon as you go to the page it sees that those required fields are empty and you get an error message. Would using session_start solve this problem?
  5. Did I note quote that this was PHP? Sorry, I'm fairly new to all of this and am unsure what I need/don't need to quote.
  6. Good afternoon, I've created two pages to handle a request form that handles the following information: length width height name email and address. Once the form is filled out and submitted, it goes to a second page where it tells you if a) the dimensions will or will not fit b)if you didn't fill in your name, email or phone, you get a reminder to do so and c)sends an email of all info put into the form. My two questions are this: 1. Can I just have 1 php page handle this instead of two? 2. How do write something so that if the contact information fields from the form aren't filled out, an email isn't generated, instead you're promted to fill out the req'd forms before continuing? My code is below. THANK YOU so much for taking the time to peruse this. The intial page with the form: <form action="accumen_request_handle.php" method="post"> <b>Describe the largest object which needs to be moved (in inches).</b> <br /><br /> Height? <input type = "text" name="height" type="text" size="2" maxlength="6" /> inches<p> Length? <input type ="text" name="length" type="text" size="2" maxlength="6" /> inches<p> Width? <input type ="text" name="width" type="text" size="2" maxlength="6" /> inches<p> <br /> Client Name: <input type ="text" name="client_name" type="text" size="25" /><p></p> Phone Number: <input type ="text" name="client_phone" type="text" size="25" maxlength="10" /><p></p> E-mail Address: <input type ="text" name="client_email" type="text" size="25" /><p></p> <input type="submit" name="submit" value="Submit Your Request" /> </form> The page that handles the form <?php //set variables from form $height = $_POST["height"]; $width = $_POST ["width"]; $length = $_POST["length"]; $name = $_POST["client_name"]; $number = $_POST["client_phone"]; $email = $_POST["client_email"]; $strip_height = strip_tags($_POST['height']); $strip_width = strip_tags($_POST['width']); $strip_length = strip_tags($_POST['length']); $strip_client_name = strip_tags($_POST['client_name']); $strip_client_phone = strip_tags($_POST['client_phone']); $strip_client_email = strip_tags($_POST['client_email']); $total_height = 90; $total_width = 91; $total_length = 192; if (($strip_height <= $total_height) and ($height) > 0 ){ //if height is less than total height print("This will fit height-wise."); } elseif($strip_height >= $total_height) { //if height is more than total height print("Sorry, but this won't fit because it's too tall."); } if (($strip_width <= $total_width) and ($width) > 0) { //if width is less than total width print ("This will fit width-wise."); } elseif($strip_width >= $total_width) { //if width is more than total width print("Sorry, but this won't fit because it's too wide."); } if (($strip_length <= $total_length) and ($length) > 0) { //if length is less than total length print("This will fit length wise."); } elseif($strip_length >= $total_length) { //if length is more than total length print("Sorry, but this won't fit because it's too long."); } //height? if (empty($_POST['height'])) { print '<p class="error">Please enter a height.</p>'; $okay = FALSE; } //width if (empty($_POST['width'])) { print '<p class="error">Please enter a width.</p>'; $okay = FALSE; } //length? if (empty($_POST['length'])) { print '<p class="error">Please enter a length.</p>'; $okay = FALSE; } //client name? if (empty($_POST['client_name'])) { print '<p class="error">Please enter your name.</p>'; $okay = FALSE; } //phone number? if (empty($_POST['client_phone'])) { print '<p class="error">Please enter your phone number.</p>'; $okay = FALSE; } //email address? if (empty($_POST['client_email'])) { print '<p class="error">Please enter your email address.</p>'; $okay = FALSE; } ?> <?php $to = "[email protected]"; $subject = "Web Order Received"; //$body = "An order from the web site has been submitted.\n"; $content ="Height is $strip_height inches.\n Length is $strip_length inches.\n Width is $strip_width inches.\n Client Name is $strip_client_name.\n Client Email is $strip_client_email.\n Client phone number is $strip_client_phone"; if (mail($to, $subject,$content)) { print("<p>Your order has been successfully sent! We'll be contacting you shortly.</p>"); } else { print("<p>Your order has not been successfully sent!</p>"); } ?> <br /> <br /> <?php //print current date and time: //set the time zone: date_default_timezone_set('America/New_York'); //now print the date and time: print date('g:i a l F j'); print " EST" ?>
×
×
  • 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.