Jump to content

BryanVest

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Everything posted by BryanVest

  1. I know the php is basic and not completed yet, but I am working on that. My next step I want the result to show on index.php when a form is submitted to calculator2.php. I just cant seem to get it. Please help! index.php <div class="post"> <h2 class="title">Calculator</h2> <hr /> <form method="post" action="calculator2.php"> Fireplace Front Width: <input type="text" name="fw"> <br /> Fireplace Back Width: <input type="text" name="bw"> <br /> Fireplace Depth: <input type="text" name="fd"> <br /> <input type="submit" name="Submit" value="Submit"> </form> Pounds Of Glass Needed: <?php echo $res1; ?> </div> calculator2.php <?php $frontwidth = $_POST['fw']; $backwidth = $_POST['bw']; $firedepth = $_POST['fd']; $x = $frontwidth + $backwidth+ $firedepth; $y = ($x / 3) * .6667; $res1 = $y *2; echo $res1; ?>
  2. I want the error to show on the HTML page above the form if they are missing the required field. I have seen this so I know its possible
  3. Hmm it started working idk why it wasnt before. I want the error to show on the HTML page above the form if they are missing the required field. I have seen this so I know its possible.
  4. Hmm there shouldnt be. There are no other PHP scripts, just HTML.
  5. Hi I am learning PHP and working on a Contact Us page with a required fields. For some reason it works great for the name and email, but always says please enter your phone number. If you guys have a better way of doing this please let me know. Also if the email is sent successfully I want it to goto the page "success.html" this part works good though just need some help please Here is the form: <form action="contact.php" method="post" id="contactform"> <ol> <li> <label for="name">Full Name <span class="red">*</span></label> <input id="name" name="name" class="text" /> </li> <li> <label for="email">Your email <span class="red">*</span></label> <input id="email" name="email" class="text" /> </li> <li> <label for="phone">Phone Number <span class="red">*</span></label> <input id="phone" name="phone" class="text" /> </li> <li> <label for="company">Company</label> <input id="company" name="company" class="text" /> </li> <li> <label for="topic">Subject<span class="red">*</span></label> <input id="topic" name="topic" class="text" /> </li> <li> <label for="comments">Message <span class="red">*</span></label> <textarea id="comments" name="comments" rows="6" cols="50"></textarea> </li> <li class="buttons"> <input type="image" name="imageField" id="imageField" src="images/send.gif" /> </li> </ol> </form> The PHP code I tried: <?php // Pick up the form data and assign it to variables $name = check_input ($_POST['name'], "Please enter your name"); $email = check_input ($_POST['email'],"Please enter your email"); $phone = check_input ($_POST['phone'], "Please enter your phone number"); $company = $_POST['company']; $topic = check_input ($_POST['topic'], "Please enter your subject"); $comments = check_input ($_POST['comments'], "Please enter your message"); function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if (strlen($data) == 0) { die($problem); } else { return $data; } } // Build the email (replace the address in the $to section with your own) $to = 'email@email.com"'; $subject = "New message: $topic"; $message = "Email: $email \n Phone: $phone \n Company: $company \n $name said: $comments"; $headers = "From: $email"; // Send the mail using PHPs mail() function mail($to, $subject, $message, $headers); // Redirect header("Location: success.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.