Jump to content

runnerjp

Members
  • Posts

    2,214
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

runnerjp's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. Below is a script to edit a forum post but the issue is it edits all the forums posts to the same message e.g b4 post1 = hey post2= how post3= are post4= you Now i select post 1 to be changed to 123 it should look like this: post1 = 123 post2= how post3= are post4= you but looks like this post1 = 123 post2= 123 post3= 123 post4= 123 <?php if (isset($_POST['edit'])) { $message = mysql_real_escape_string($_POST['message']); $query = "UPDATE forumtutorial_posts SET post = '$message' WHERE postid=".$getreplies3['postid']." "; mysql_query($query) or die('Error, query failed'); } else { echo $getreplies3['postid'] ; $threadid = $CONT_ID; ?> <script src="../../css/SpryCollapsiblePanel.js" type="text/javascript"></script> <link href="http://www.runningprofiles.com/css/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" /> <div id="CollapsiblePanel<?PHP // I had to add $CONT_ID that is set in the script that includes this. and ive done it again for the "tabindex" just to ensure it works! echo $CONT_ID; ?>" class="CollapsiblePanel"> <div class="CollapsiblePanelTab" tabindex="<?PHP echo $CONT_ID; ?>"> Edit</div> <div class="CollapsiblePanelContent"> <form name='input' action='<?php echo $filename ;?>' method='post'> <div align="center"> <label> <textarea class='inputforum' name="message" id="message" cols="500" rows="5"><? echo $message; ?></textarea> </label> <input type="checkbox" name="deletepost" value="deletepost" /> delete post <br/> <br/> <input type='submit' name='edit' class="submit-btn" value='' /> </div> </form> <? } ?></div> </div> <script type="text/javascript"> <!-- <?PHP //Ive added the variable $CONT_ID here aswell. THIS IS REQUIRED FOR THE //JS to work! ?> var CollapsiblePanel<?PHP echo $CONT_ID; ?> = new Spry.Widget.CollapsiblePanel("CollapsiblePanel<?PHP echo $CONT_ID; ?>", {contentIsOpen:false}); //--> </script>
  2. Sure thing // Find out the total number of pages depending on the limit set $numofpages=$rows / $page_rows; $totalpages=ceil($numofpages); // Start links for pages $maxpage =$totalpages == 0 ? 1 : $totalpages; // add this line echo "Page " . $pagenum . " of " . $maxpage . "</center>"; // change this // Sets link for previous 25 and return to page 1 if ($pagenum != 1) { $pageprev=($pagenum - 1); echo "<center><a href=\"" . $_SERVER['PHP_SELF'] . "?page=message&forum=$forum&id=$forumpostid&pagenum=1\"><<</a> "; echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=message&forum=$forum&id=$forumpostid&pagenum=$pageprev\">PREV </a> "; } else { echo "<center>PREV "; } // Loop thru all the pages and echo out the links for ($i=1; $i <= $numofpages; $i++) { if ($i == $pagenum) { echo "[" . $i . "] "; } else { echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=message&forum=$forum&id=$forumpostid&pagenum=$i\">$i</a> "; } } // Check for straglers after the limit blocks if (($rows % $page_rows) != 0) { if ($i == $pagenum) { echo "[" . $i . "] "; } else { echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=message&forum=$forum&id=$forumpostid&pagenum=$i\">$i</a> "; } } // Print out the Next 25 and Goto Last page links if (($rows - ($page_rows * $pagenum)) > 0) { $pagenext=$pagenum++; echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=message&forum=$forum&id=$forumpostid&pagenum=$pagenext\">NEXT </a> "; echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=message&forum=$forum&id=$forumpostid&pagenum=$totalpages\">>></a> </center>"; } else { echo("NEXT </center> <br />"); }
  3. At the moment i have added some code to add a number to the post so looks liek this 1# 2# 3# 4# ect The problem is now i have added pagination to it when i go to page 2 it starts form 2# again... any way i can make it carry on from where it left off?? $counter2 = 1; $counter2++; echo $counter2;
  4. What am i doing wrong here??? "Select * from forumtutorial_posts where parentid='572' ORDER BY showtime 10 ASC"; //getting replies
  5. 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"; } ?>
  6. nope thats not where to stick it sadly any 1 else?
  7. 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
  8. 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
  9. so would this be correct if (function show_form()) { echo 'her'; } else if(isset($_POST["basic"])) { check_form();
  10. ah yes ty... instead of opening a new thread can i ask echo 'her'; else } if(isset($_POST["basic"])) { how would this work properly
  11. i get unexpected t_sting...all i want to do is make the text green lol
  12. how would i get this to work $message="<span class="style1">Your profile has been created</span>";
  13. ahh yes thats good .. how would i stop ' or @ being used?
  14. humm its intresting 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 empty or contains wrong data<br>"; } if (($_POST["last_name"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["last_name"]))) { $error['last_name'] = true; $print_again = true; $message = "The last name field is empty or contains wrong data<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="All Fields are valid <br>"; $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"; if i enter "£$% symbols for example then it will not not me submit form.. thats good but it does not show any error message at all BUT if i enter 1234 then it lets me submit it with the message All Fields are valid
×
×
  • 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.