runnerjp Posted May 26, 2008 Share Posted May 26, 2008 how would i get this to work $message="<span class="style1">Your profile has been created</span>"; Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted May 26, 2008 Share Posted May 26, 2008 What doesn't work about it, and what would you like it to do? Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 26, 2008 Author Share Posted May 26, 2008 i get unexpected t_sting...all i want to do is make the text green lol Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted May 26, 2008 Share Posted May 26, 2008 It's because you are using double quotes within double quotes. Do this $message="<span class='style1'>Your profile has been created</span>"; Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 26, 2008 Author Share Posted May 26, 2008 ah yes ty... instead of opening a new thread can i ask echo 'her'; else } if(isset($_POST["basic"])) { how would this work properly Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted May 26, 2008 Share Posted May 26, 2008 The code you just posted doesn't make any sense. You would have to explain what your trying to do. To make your code make sense, it would need to be something like this if (some condition) { echo 'her'; } else if(isset($_POST["basic"])) { //code here } Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 26, 2008 Author Share Posted May 26, 2008 so would this be correct if (function show_form()) { echo 'her'; } else if(isset($_POST["basic"])) { check_form(); Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted May 26, 2008 Share Posted May 26, 2008 so would this be correct if (function show_form()) { echo 'her'; } else if(isset($_POST["basic"])) { check_form(); I don't know what your function show_form() looks like, but if it returns a value of TRUE or FALSE, then you can do this: if (show_form()) { echo 'her'; } else if(isset($_POST["basic"])) { check_form(); } I can only tell you if the syntax is correct, other than that...I have no idea what your trying to accomplish. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted May 26, 2008 Share Posted May 26, 2008 note: stuff inside opening and closing curly brackets is called a 'block' of code. there can't be an opening curly bracket without a closing one { // opening curly bracket // here would be a block of code. } // MUST ALWAYS have a closing curly bracket. Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 26, 2008 Author Share Posted May 26, 2008 humm thats not wrokign lol ok if i show you my code it might help <? function error_bool($error, $field) { if($error[$field]) { print("<td style=color:red>"); } else { print("<td>"); } } function show_form() { global $HTTP_POST_VARS, $print_again, $error; ?> <form id="FormName" action='<?php "$_SERVER[php_SELF]" ?>' method="post" name="basic"> <table width="440" border="0" align="center" cellpadding="0" cellspacing="2"> <tr><td colspan="3"> </td> </tr> <tr> <td><div align="right"> <label for="dob">First name</label> </div></td> <td colspan="2"><input class="inputedit" id="first_name" name="first_name" type="text" size="25" value="" maxlength="255" /></td> </tr> <tr> <td width="150"><div align="right"> <label for="dob"></label> </div></td> </tr><tr><td colspan="2"> </td> </tr> <tr> <td width="150"><div align="right"> <label for="last_name">Club</label> </div></td> <td colspan="2"><p> <label for="birthday"></label> <?php $lines = file('runningclubs.txt'); echo '<select class="inputedit" id="club" name="club">'; foreach($lines as $line) { echo '<option>'.$line.'</option>'; } echo '</select>';?> </p></td> </tr> <tr> <td width="150" align="right">status</td> <td colspan="2"><? } if(isset($_POST["basic"])) { check_form(); } else { show_form(); } function check_form() { global $HTTP_POST_VARS, $error, $print_again; $error['error'] = false; if (($_POST["first_name"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["first_name"]))) { $error['first_name'] = true; $print_again = true; $message = "The first name field is either empty or incorrect data was input.<br>"; } if (($_POST["last_name"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["first_name"]))) { $error['last_name'] = true; $print_again = true; $message="The last name field is either empty or incorrect data was input.<br>"; } if($_POST["club"]=="") { $error['club'] = true; $print_again = true; $message="Please select a club<br>"; } if($_POST["birthyear"]=="-DAY-") { $error['birthyear'] = true; $print_again = true; $message="Please select a dob<br>"; } if($_POST["birthmonth"]=="-MONTH-") { $error['birthmonth'] = true; $print_again = true; $message="Please select a dob<br>"; } if($_POST["birthday"]=="-YEAR-") { $error['birthday'] = true; $print_again = true; $message="Please select a dob<br>"; } if($print_again) { show_form(); } else { show_form(); $message="<span class='style1'>Your profile has been created</span>"; $id = mysql_real_escape_string( $_POST['id']); $club = mysql_real_escape_string( $_POST['club']); $first_name = mysql_real_escape_string( $_POST['first_name']); $last_name = mysql_real_escape_string( $_POST['last_name']); $gender = mysql_real_escape_string( $_POST['gender']); $birthyear = mysql_real_escape_string( $_POST['birthyear']); $birthmonth = mysql_real_escape_string( $_POST['birthmonth']); $birthday = mysql_real_escape_string( $_POST['birthday']); $dob = $birthday.'-'.$birthmonth.'-'.$birthyear; $update = "UPDATE users SET new_user='1',dob='$dob', club= '$club', first_name = '$first_name', gender = '$gender', last_name = '$last_name' WHERE id='$id' "; $result = mysql_query($update); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$result) { $er = 'Invalid query: ' . mysql_error() . "\n"; $er .= 'Whole query: ' . $query; die($er); }} echo ' <p class="error">' . $message . '</p>' . "\n"; } ?> so basicly where it says echo ' <p class="error">' . $message . '</p>' . "\n"; i would like it to say please fill in the form, if a user has not yet submitted the form Quote Link to comment Share on other sites More sharing options...
plutomed Posted May 26, 2008 Share Posted May 26, 2008 It's because you are using double quotes within double quotes. Do this $message="<span class='style1'>Your profile has been created</span>"; You could also just put a back slash infront of the double quotes. I think it's called escaping. ??? eg. $message="<span class=\"style1\">Your profile has been created</span>"; Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 26, 2008 Author Share Posted May 26, 2008 bmp for so basicly where it says echo ' <p class="error">' . $message . '</p>' . "\n"; i would like it to say please fill in the form, if a user has not yet submitted the form Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted May 26, 2008 Share Posted May 26, 2008 <?php elseif(!isset($_POST['basic'])){ //error }?> Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 27, 2008 Author Share Posted May 27, 2008 nope thats not where to stick it sadly any 1 else? Quote Link to comment Share on other sites More sharing options...
haku Posted May 27, 2008 Share Posted May 27, 2008 First off, before anything, you should stop using <? and start using <?php if not only because it will make your code easier to read when you post it on this site, which means you are likely to get help sooner. But you should also do it because the use of short tags ('<?') will not work on some servers, and on other servers the server admin may change it unexpectedly. It's sloppy scripting that can cause problems. Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 27, 2008 Author Share Posted May 27, 2008 sorry here you go <?php function error_bool($error, $field) { if($error[$field]) { print("<td style=color:red>"); } else { print("<td>"); } } function show_form() { global $HTTP_POST_VARS, $print_again, $error; ?> <form id="FormName" action='<?php "$_SERVER[php_SELF]" ?>' method="post" name="basic"> <table width="440" border="0" align="center" cellpadding="0" cellspacing="2"> <tr><td colspan="3"> </td> </tr> <tr> <td><div align="right"> <label for="dob">First name</label> </div></td> <td colspan="2"><input class="inputedit" id="first_name" name="first_name" type="text" size="25" value="" maxlength="255" /></td> </tr> <tr> <td width="150"><div align="right"> <label for="dob"></label> </div></td> </tr><tr><td colspan="2"> </td> </tr> <tr> <td width="150"><div align="right"> <label for="last_name">Club</label> </div></td> <td colspan="2"><p> <label for="birthday"></label> <?php $lines = file('runningclubs.txt'); echo '<select class="inputedit" id="club" name="club">'; foreach($lines as $line) { echo '<option>'.$line.'</option>'; } echo '</select>';?> </p></td> </tr> <tr> <td width="150" align="right">status</td> <td colspan="2"><?php } if(isset($_POST["basic"])) { check_form(); } else { show_form(); } function check_form() { global $HTTP_POST_VARS, $error, $print_again; $error['error'] = false; if (($_POST["first_name"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["first_name"]))) { $error['first_name'] = true; $print_again = true; $message = "The first name field is either empty or incorrect data was input.<br>"; } if (($_POST["last_name"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["first_name"]))) { $error['last_name'] = true; $print_again = true; $message="The last name field is either empty or incorrect data was input.<br>"; } if($_POST["club"]=="") { $error['club'] = true; $print_again = true; $message="Please select a club<br>"; } if($_POST["birthyear"]=="-DAY-") { $error['birthyear'] = true; $print_again = true; $message="Please select a dob<br>"; } if($_POST["birthmonth"]=="-MONTH-") { $error['birthmonth'] = true; $print_again = true; $message="Please select a dob<br>"; } if($_POST["birthday"]=="-YEAR-") { $error['birthday'] = true; $print_again = true; $message="Please select a dob<br>"; } if($print_again) { show_form(); } else { show_form(); $message="<span class='style1'>Your profile has been created</span>"; $id = mysql_real_escape_string( $_POST['id']); $club = mysql_real_escape_string( $_POST['club']); $first_name = mysql_real_escape_string( $_POST['first_name']); $last_name = mysql_real_escape_string( $_POST['last_name']); $gender = mysql_real_escape_string( $_POST['gender']); $birthyear = mysql_real_escape_string( $_POST['birthyear']); $birthmonth = mysql_real_escape_string( $_POST['birthmonth']); $birthday = mysql_real_escape_string( $_POST['birthday']); $dob = $birthday.'-'.$birthmonth.'-'.$birthyear; $update = "UPDATE users SET new_user='1',dob='$dob', club= '$club', first_name = '$first_name', gender = '$gender', last_name = '$last_name' WHERE id='$id' "; $result = mysql_query($update); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$result) { $er = 'Invalid query: ' . mysql_error() . "\n"; $er .= 'Whole query: ' . $query; die($er); }} echo ' <p class="error">' . $message . '</p>' . "\n"; } ?> Quote Link to comment 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.