Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I eliminate the use of die() in this script, so that the HTML at the bottom still runs?
    primarykey
    data
    text
    <p>When I initially wrote this script, the site design did not require the execution of the html after the die() functions. Now it does. I realize I can copy the end of the HTML code into each of the die() statements, but it contains a php include file (footer.inc.php) which is then ignored. (This is the workaround that I am going with at the moment, so the page looks OK but does not contain the footer.)</p> <p>I tried switching the die() functions in the first sequence to if() and elseif() functions, but then it displays both the die() message and the message after the email code that indicates the email function was successful.</p> <p>I am sure there is a way to have the script execute only one of these statements without using the die(), but I can't figure it out. Any tips would be greatly appreciated!</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head&gt; &lt;meta name="google-site-verification" content="0QW3jKsbHBGLvnLgLIoSHRuxjHBUI_MMQ0wn9J-4eo4" /&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=us-ascii" /&gt; &lt;link href="../stylesheet.css" rel="stylesheet" type="text/css" /&gt; &lt;link rel="icon" href="../images/favicon.ico" type="image/jpg" /&gt; &lt;title&gt;Center Court - Schedule a racquet pick-up&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="container"&gt; &lt;div id="liquid-round"&gt; &lt;div class="top"&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class="center-content"&gt; &lt;div id="header"&gt; &lt;?php include("../header2.inc.php"); ?&gt; &lt;/div&gt; &lt;div id="nav"&gt; &lt;?php include("../nav.inc.php"); ?&gt; &lt;/div&gt; &lt;div id="phpscreen"&gt; &lt;?php //retrieve details from POST submission $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $address = $_POST['address']; $city = $_POST['city']; $retrieval = $_POST['retrieval']; $needed = $_POST['needed']; $string = $_POST['string']; $outofstock = $_POST['outofstock']; $tension = $_POST['tension']; $scale = $_POST['scale']; $extras= $_POST['extras']; $notes = $_POST['notes']; //validate sumbitted data if (empty($name)){ die('&lt;p class="center"&gt;Please provide your name.&lt;/p&gt; &lt;form&gt;&lt;p class="center"&gt;&lt;input type="button" value="Go back" onClick="history.go(-1);return true;"&gt; &lt;/p&gt;&lt;/form&gt;'); } if (empty($email)){ die('&lt;p class="center"&gt;Please provide your email.&lt;/p&gt; &lt;form&gt;&lt;p class="center"&gt;&lt;input type="button" value="Go back" onClick="history.go(-1);return true;"&gt; &lt;/p&gt;&lt;/form&gt;'); } if (empty($phone)){ die('&lt;p class="center"&gt;Please provide your phone number.&lt;/p&gt; &lt;form&gt;&lt;p class="center"&gt;&lt;input type="button" value="Go back" onClick="history.go(-1);return true;"&gt; &lt;/p&gt;&lt;/form&gt;'); } if (empty($address)){ die('&lt;p class="center"&gt;Please provide your address.&lt;/p&gt; &lt;form&gt;&lt;p class="center"&gt;&lt;input type="button" value="Go back" onClick="history.go(-1);return true;"&gt; &lt;/p&gt;&lt;/form&gt;'); } if (empty($city)){ die('&lt;p class="center"&gt;Please provide your city.&lt;/p&gt; &lt;form&gt;&lt;p class="center"&gt;&lt;input type="button" value="Go back" onClick="history.go(-1);return true;"&gt; &lt;/p&gt;&lt;/form&gt;'); } if (empty($needed)){ die('&lt;p class="center"&gt;Please provide the date and time you need your racquet.&lt;/p&gt; &lt;form&gt;&lt;p class="center"&gt;&lt;input type="button" value="Go back" onClick="history.go(-1);return true;"&gt; &lt;/p&gt;&lt;/form&gt;'); } //formulate email message $to = 'centercourtstringing@yahoo.com'; $from = 'centercourtstringing.com'; $subject = 'Contact from centercourtstringing.com'; $body = " Name: $name\r\n Email: $email\r\n Phone number: $phone\r\n Address: $address\r\n City: $city\r\n Retrieval method: $retrieval\r\n Needed by: $needed\r\n String type: $string\r\n Similar or upgrade OK: $outofstock\r\n Tension: $tension\r\n Unsure scale: $scale\r\n Extras: $extras\r\n Special requests or notes: $notes\r\n"; if(mail($to, $subject, $body, "From $from")){ echo '&lt;p&gt;Your pick-up has been requested. You should receive confirmation shortly via e-mail or phone. If you do not hear from us by the end of the day, please call Center Court Tennis Shop at 203-966-2543.&lt;/p&gt;&lt;p class="center"&gt;&lt;a href="http://centercourtstringing.com"&gt;Return to home page&lt;/a&gt;&lt;/p&gt;'; }else{ die('&lt;p&gt;Sorry, there was a mail delivery error. please call Center Court Tennis Shop at 203-966-2543 to schedule your pick-up.&lt;/p&gt;&lt;p class="center"&gt;&lt;a href="http://centercourtstringing.com"&gt;Return to home page&lt;/a&gt;&lt;/p&gt;'); } ?&gt; &lt;/div&gt; &lt;div id="footer"&gt; &lt;?php include("../footer.inc.php"); ?&gt; &lt;/div&gt; &lt;!--end footer--&gt; &lt;/div&gt;&lt;!--end center content--&gt; &lt;div class="bottom"&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt;&lt;!--end liquid-round--&gt; &lt;/div&gt;&lt;!--end container--&gt; &lt;script type="text/javascript"&gt; var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-18191457-2']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); &lt;/script&gt;&lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload