jd2007 Posted July 21, 2007 Share Posted July 21, 2007 order.php <?php $error=$_GET["errora"]; echo $error; $error2=$_GET["errorb"]; echo $error2; echo " <style> #form { background-color:#CC99FF; border-style:solid; border-color:#660099; } #margin { margin-left: 30px; } #marginorder { margin-left: 60px; margin-bottom: 20px; } </style> <form id=form method=post action=ordering.php> <h3 id=margin>Order A Cellphone</h3> <label for=Name id=margin><b>Name:</b></label><input type=text name=name /><br><br> <label for=E-mail id=margin><b>E-mail:</b></label><input type=text name=email /><br><br> <label for=Products id=margin><b>Products:</b></label><br> <input id=margin type=checkbox name=hp1 /><label for=Nokia 3100><i>Nokia 3100</i></label><br> <input id=margin type=checkbox name=hp2 /><label for=Nokia 3300><i>Nokia 3300</i></label><br> <input id=margin type=checkbox name=hp3 /><label for=Nokia 390><i>Nokia 390</i></label><br> <input id=margin type=checkbox name=hp4 /><label for=Nokia 400><i>Nokia 400</i></label><br><br> <label for=Comments id=margin><b>Comments:</b></label><br> <textarea id=margin name=comments rows=10 cols=20> </textarea><br><br> <input id=marginorder type=submit value=Order /> </form>"; ?> ordering.php <?php if($_POST["name"]&&$_POST["email"]&&$_POST["comments"]&&($_POST["hp1"]||$_POST["hp2"]||$_POST["hp3"]||$_POST["hp4"])) { if(ereg("^[a-zA-Z0-9\_\-\.]+@[a-zA-Z]+\.[a-zA-Z\.\-]+$",$_POST["email"])) { $_POST["hp1"] ? $x = 1 : $x = 0; $_POST["hp2"] ? $y = 1 : $y = 0; $_POST["hp3"] ? $z = 1 : $z = 0; $_POST["hp4"] ? $w = 1 : $w = 0; $to=$_POST["email"]; $subject="Orders"; $message="$_POST[name] has ordered $x Nokia 3100, $y Nokia 3300, $z Nokia 390 and $w Nokia 400."; mail($to, $subject, $message); } else { $error2="<script>alert('Please enter a valid e-mail.');</script>"; header("location:order.php?errorb=$error2"); } } else { $error="<script>alert('Please make sure all fields are filled.');</script>"; header("location:order.php?errora=$error"); } ?> everytime i click Order, nothing happens. only the url in the address bar changes from http://localhost/order.php to http://localhost/order.php?errora=%3Cscript%3Ealert('Please%20make%20sure%20all%20fields%20are%20filled.');%3C/script%3E Link to comment https://forums.phpfreaks.com/topic/61087-why-is-the-code-below-not-working/ Share on other sites More sharing options...
DeadEvil Posted July 21, 2007 Share Posted July 21, 2007 <?php echo $_GET["errora"]; echo $_GET["errorb"]; $content = ""; $content .= "<style>"; $content .= "#form { background-color:#CC99FF; border-style:solid; border-color:#660099; }"; $content .= "#margin { margin-left: 30px; }"; $content .= "#marginorder { margin-left: 60px; margin-bottom: 20px; }</style>"; echo $content; $content2 = ""; $content2 = "<form id=\"form\" method=\"post\" action=\"ordering.php\">"; $content2 = "<h3 id=\"margin\">Order A Cellphone</h3>"; $content2 = "<label for=\"Name\" id=\"margin\"><b>Name:</b></label><input type=\"text\" name=\"name\" /><br><br>"; $content2 = "<label for=\"E-mail\" id=\"margin\"><b>E-mail:</b></label><input type=\"text\" name=\"email\" /><br><br>"; $content2 = "<label for=\"Products\" id=\"margin\"><b>Products:</b></label><br>"; $content2 = "<input id=\"margin\" type=\"checkbox\" name=\"hp1\" /><label for=\"Nokia 3100\"><i>Nokia 3100</i></label><br>"; $content2 = "<input id=\"margin\" type=\"checkbox\" name=\"hp2\" /><label for=\"Nokia 3300\"><i>Nokia 3300</i></label><br> "; $content2 = "<input id=\"margin\" type=\"checkbox\" name=\"hp3\" /><label for=\"Nokia 390\"><i>Nokia 390</i></label><br> "; $content2 = "<input id=\"margin\" type=\"checkbox\" name=\"hp4\" /><label for=\"Nokia 400\"><i>Nokia 400</i></label><br><br>"; $content2 = "<label for=\"Comments\" id=\"margin\"><b>Comments:</b></label><br> "; $content2 = "<textarea id=\"margin\" name=\"comments\" rows=\"10\" cols=\"20\"></textarea><br><br>"; $content2 = "<input id=\"marginorder\" type=\"submit\" value=\"Order\" name=\"Order\" />"; $content2 = "</form>"; echo $content2; ?> <?php if($_POST["Order"]) { if(ereg("^[a-zA-Z0-9\_\-\.]+@[a-zA-Z]+\.[a-zA-Z\.\-]+$",$_POST["email"])) { $_POST["hp1"] ? $x = 1 : $x = 0; $_POST["hp2"] ? $y = 1 : $y = 0; $_POST["hp3"] ? $z = 1 : $z = 0; $_POST["hp4"] ? $w = 1 : $w = 0; $to=$_POST["email"]; $subject="Orders"; $message="$_POST[name] has ordered $x Nokia 3100, $y Nokia 3300, $z Nokia 390 and $w Nokia 400."; mail($to, $subject, $message); } else { $error2="<script>alert('Please enter a valid e-mail.');</script>"; header("location:order.php?errorb=$error2"); } } else { $error="<script>alert('Please make sure all fields are filled.');</script>"; header("location:order.php?errora=$error"); } ?> Link to comment https://forums.phpfreaks.com/topic/61087-why-is-the-code-below-not-working/#findComment-304013 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.