Antec Posted June 3, 2007 Share Posted June 3, 2007 This is my issue...This is part of a bigger script i am working on and what this part of the coding does is it looks to see if the recruiting status for the site is either open or closed...now as you can see if it is closed it is supposed to show that message and if it is open it is supposed to shot the "Join Us" form...now it all works great except for the fact that i want to be able to use a "Form Validator" that will have a pop-up for leaving a feild blank or invalid email format or leaving the checkbox blank...but the issue im having is that i cannot add any code into the "echo ' " without it coming up with syntax errors...if someone could please post a solution for this you would make me very happy...I have attached the coding as it would be way to big to post...the lines in question are 182-234 [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/54082-i-need-some-help/ Share on other sites More sharing options...
chigley Posted June 3, 2007 Share Posted June 3, 2007 if($_GET['view'] == "JoinUs") { require("functions.php"); $query = @mysql_query("SELECT recruiting, security_status, total FROM status"); $row_status = mysql_fetch_array($query); if($row_status['total'] >= 350 || $row_status['recruiting'] == 1) { echo' <font color="#76A5D5" size="4" face="verdana"><b>Recruiting Is Closed!</b></font>'; } else { echo ' <form method="post" name="JoinRequest" action="sendit.php">'; // <--- Missed '; here <?php $ipi = getenv("REMOTE_ADDR"); $httprefi = getenv ("HTTP_REFERER"); $httpagenti = getenv ("HTTP_USER_AGENT"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/54082-i-need-some-help/#findComment-267346 Share on other sites More sharing options...
Antec Posted June 3, 2007 Author Share Posted June 3, 2007 ok cool thanks but how do i validate the text feilds including the checkbox? Quote Link to comment https://forums.phpfreaks.com/topic/54082-i-need-some-help/#findComment-267349 Share on other sites More sharing options...
chigley Posted June 3, 2007 Share Posted June 3, 2007 <?php function valid_email($address) { // check an email address is possibly valid if (ereg('^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$', $address)) return true; else return false; } if(isset($_POST["submit"])) { // Rename submit to the name of your form submit field $errors = array(); if(!valid_email($_POST["email"])) { // Rename email to the name of your form's email field $errors[] = "You must enter a valid email address"; } if(!isset($_POST["textfield"])) { // Example test to see if a field is valid. Duplicate as required $errors[] = "You must fill in all fields."; } if(count($errors) > 0) { foreach($errors as $error) { echo "<span style=\"font-color: red;\">Error: {$error}</span><br />\n"; } } else { // Process the form } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/54082-i-need-some-help/#findComment-267351 Share on other sites More sharing options...
Antec Posted June 3, 2007 Author Share Posted June 3, 2007 Will that create a pop-up window on any error and will it also make sure that you cannot submitt the form unles the checkbox is checked? and where do i put that? before or after the form? Quote Link to comment https://forums.phpfreaks.com/topic/54082-i-need-some-help/#findComment-267352 Share on other sites More sharing options...
Antec Posted June 3, 2007 Author Share Posted June 3, 2007 BUMP Quote Link to comment https://forums.phpfreaks.com/topic/54082-i-need-some-help/#findComment-267360 Share on other sites More sharing options...
chigley Posted June 3, 2007 Share Posted June 3, 2007 You're heading towards Javascript here, use this for the checkbox validation: [pre]<input type="checkbox" name="confirm" onclick="this.form['submit'].disabled=false; this.form['confirm'].disabled=true;"/><br /> <input name="submit" type="submit" value="Submit" disabled="disabled" />[/pre] Quote Link to comment https://forums.phpfreaks.com/topic/54082-i-need-some-help/#findComment-267362 Share on other sites More sharing options...
Antec Posted June 3, 2007 Author Share Posted June 3, 2007 javascript should work in there wounldn't it? That is if you know how to do it in javascript...if not that cool i thank you for your help...but if you can do it in javascript that would be cool...cause even if we couldn't add it right to that code we could link to it in an "include or require" formvalidation.js or something Quote Link to comment https://forums.phpfreaks.com/topic/54082-i-need-some-help/#findComment-267363 Share on other sites More sharing options...
Antec Posted June 3, 2007 Author Share Posted June 3, 2007 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/54082-i-need-some-help/#findComment-267371 Share on other sites More sharing options...
chigley Posted June 3, 2007 Share Posted June 3, 2007 Read through this article and see if you can put something together yourself instead of me doing it for you! Quote Link to comment https://forums.phpfreaks.com/topic/54082-i-need-some-help/#findComment-267373 Share on other sites More sharing options...
Antec Posted June 3, 2007 Author Share Posted June 3, 2007 Cool, Thanks but the only reason i ask is because i know nuthin about javascript but ya...where would i but the validation script after i have made it? Quote Link to comment https://forums.phpfreaks.com/topic/54082-i-need-some-help/#findComment-267374 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.