Jump to content

Cyberspace

Members
  • Posts

    46
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Cyberspace's Achievements

Member

Member (2/5)

0

Reputation

  1. Hey thanks for the reply, im just wondering do i put that line in: </font><form method="post" class="addwalkerform" action=""> inside form action?
  2. Is there a simple way of doing this?
  3. I have a form that adds records to a database, in my code i have a table above the form that displays the table information, i would like when the user submits the form that the page automatically displays the record and refreshes the page with the table updated with the record, can anyone provide some help on how to do this? My code is: <?php $WalkNo = $_GET['WalkNo']; $WalkNo = mysql_real_escape_string($WalkNo); $Venue = mysql_real_escape_string($Venue); $WalkDate = mysql_real_escape_string($WalkDate); $Leader = mysql_real_escape_string($Leader); $account = mysql_fetch_array(mysql_query("SELECT * FROM walks WHERE WalkNo='$WalkNo'")); ?> </table> <table class="join" cellspacing="0" width="861"> <tr> <td class="Header">WalkNo</td> <td class="Body"><?php echo $account["WalkNo"]; ?></td> </tr> <tr> <td class="Header">Venue</td> <td class="Body"><?php echo $account["Venue"]; ?></td> </tr> <tr> <td class="Header">WalkDate</td> <td class="Body"><?php echo $account["WalkDate"]; ?></td> </tr> <tr> <td class="Header">Leader</td> <td class="Body"><?php echo $account["Leader"]; ?></td> </tr> </table> <p> <hr class="hr_blue"/></p> <font face="Arial" size="3"> Walk Participants</font> <p></p> <?php $WalkNo = $_GET['WalkNo']; $query = "SELECT w.WalkNo, m.MemberRef, m.Forename, m.Surname, w.DateJoined FROM members m, walker w WHERE w.MemberRef=m.MemberRef AND w.WalkNo='$WalkNo'"; $result = mysql_query($query) or die('Query error!<br />Error:' . mysql_error() . 'Query: <pre>' . $query . '</pre>'); if(mysql_num_rows($result) == 0) { print "No Participants exist"; } else{ ?> <table class="join" cellspacing="0" width="861"> <tr> <td class="Header">WalkNo</td> <td class="Header">Member Ref</td> <td class="Header">Forename</td> <td class="Header">Surname</td> <td class="Header">DateJoined</td> </tr> <?php while ($account = @mysql_fetch_assoc($result)) { ?> <tr> <td class="Body"><?php echo $account["WalkNo"]; ?></td> <td class="Body"><?php echo $account["MemberRef"]; ?></td> <td class="Body"><?php echo $account["Forename"]; ?></td> <td class="Body"><?php echo $account["Surname"]; ?></td> <td class="Body"><?php echo $account["DateJoined"]; ?></td> </tr> <?php } } ?> </table> <?php if (isset($_POST['submit'])) { $error_stat = 0; $message = 0; $MemberRef_message = ''; $Password_message = ''; $Password2_message = ''; $User_message = ''; $Walk_message = ''; $Add_message = ''; $MemberRef = mysql_real_escape_string(stripslashes($_POST['MemberRef'])); $Password = mysql_real_escape_string(stripslashes($_POST['Password'])); //Error checking // MemberRef Check) if (!$MemberRef) { //Set the error_stat to 1, which means that an error has occurred $error_stat = 1; //Set the message to tell the user to enter a username $MemberRef_message = '*Please enter MemberRef*'; } else if (!ctype_digit($MemberRef)) { $error_stat = 1; $MemberRef_message .= '*MemberRef must be a number*'; } if (!$Password) { //Set the error_stat to 1, which means that an error has occurred $error_stat = 1; //Set the message to tell the user to enter a password $Password_message = '*Please enter a Password*'; } // Walker Check if (isset($_POST['submit']) && $error_stat == 0) { $account = mysql_query("SELECT * FROM walker WHERE MemberRef='$MemberRef'"); $numrows = mysql_num_rows($account); //get rows returned if($numrows == 0) { $error_stat = 1; $Walk_message = '*Member Ref number does not exist*'; } // MemberRef and Password Check else if (isset($_POST['submit']) && $error_stat == 0) { $account = mysql_query("SELECT * FROM members WHERE MemberRef='$MemberRef' AND Password='$Password'"); $numrows = mysql_num_rows($account); //get rows returned if($numrows == 0) { $error_stat = 1; $User_message = '*Incorrect Password*'; } if (isset($_POST['submit']) && $error_stat == 0) { $account = mysql_query("SELECT * FROM walker WHERE MemberRef='$MemberRef' AND WalkNo='$WalkNo'"); $numrows = mysql_num_rows($account); //get rows returned if($numrows == 1) { $error_stat = 1; $Walk_message = '*User is already on walk*'; } if (isset($_POST['submit']) && $error_stat == 0) { mysql_query("INSERT INTO walker (MemberRef, WalkNo, DateJoined) VALUES ('$MemberRef', '$WalkNo',NOW())"); echo "<h4>You has been successfully added to the walk program</h4>"; } } } } } ?> <hr class="hr_blue"/></p><font face="Arial" size="3">Join Walk </font><form method="post" class="addwalkerform" action=""> </font> <fieldset> <label for="MemberRef">MemberRef:</label> <input name="MemberRef" type="text" id="MemberRef" value="<?php echo $_POST['MemberRef']; ?>"/> <span class="redboldtxt"><?php echo "$MemberRef_message";?></fieldset></span> </fieldset> <fieldset> <label for="Password">Password:</label> <input name="Password" type="text" id="Password" value="<?php echo $_POST['Password']; ?>"/> <span class="redboldtxt"><?php echo "$Password_message";?></fieldset></span> <span class="redboldtxt"><?php echo "$Password2_message";?></fieldset></span> <fieldset> <p class="submit"><input type="submit" name="submit" value="Join Walk" /> <span class="redboldtxt"><?php echo "$User_message";?></fieldset></span> <p></p> <span class="redboldtxt"><?php echo "$Walk_message";?></fieldset></span> <span class="redboldtxt"><?php echo "$Add_message";?></fieldset></span> </fieldset> </fieldset> </form>
  4. I have a form that validates on submit and then send the information to the database, one of the checks validates that the user is not already added to the database ie "User is already on walk" this works fine but i have a message that is outputted when the form is submit and no errors have occurred, "You has been successfully added to the walk program", this appears if the "User is already on walk" error has occurred, i need "You has been successfully added to the walk program" to only appear if no errors have occurred. Can anyone help? Code is <?php if (isset($_POST['submit'])) { $error_stat = 0; $message = 0; $MemberRef_message = ''; $Password_message = ''; $Password2_message = ''; $User_message = ''; $Walk_message = ''; $Add_message = ''; $MemberRef = mysql_real_escape_string(stripslashes($_POST['MemberRef'])); $Password = mysql_real_escape_string(stripslashes($_POST['Password'])); //Error checking // MemberRef Check) if (!$MemberRef) { //Set the error_stat to 1, which means that an error has occurred $error_stat = 1; //Set the message to tell the user to enter a username $MemberRef_message = '*Please enter MemberRef*'; } else if (!ctype_digit($MemberRef)) { $error_stat = 1; $MemberRef_message .= '*MemberRef must be a number*'; } if (!$Password) { //Set the error_stat to 1, which means that an error has occurred $error_stat = 1; //Set the message to tell the user to enter a password $Password_message = '*Please enter a Password*'; } // Walker Check if (isset($_POST['submit']) && $error_stat == 0) { $account = mysql_query("SELECT * FROM walker WHERE MemberRef='$MemberRef'"); $numrows = mysql_num_rows($account); //get rows returned if($numrows == 0) { $error_stat = 1; $Walk_message = '*Member Ref number does not exist*'; } // MemberRef and Password Check else if (isset($_POST['submit']) && $error_stat == 0) { $account = mysql_query("SELECT * FROM members WHERE MemberRef='$MemberRef' AND Password='$Password'"); $numrows = mysql_num_rows($account); //get rows returned if($numrows == 0) { $error_stat = 1; $User_message = '*Incorrect Password*'; } if (isset($_POST['submit']) && $error_stat == 0) { $account = mysql_query("SELECT * FROM walker WHERE MemberRef='$MemberRef' AND WalkNo='$WalkNo'"); $numrows = mysql_num_rows($account); //get rows returned if($numrows == 1) { $error_stat = 1; $Walk_message = '*User is already on walk*'; } if (isset($_POST['submit']) && $error_stat == 0) { mysql_query("INSERT INTO walker (MemberRef, WalkNo, DateJoined) VALUES ('$MemberRef', '$WalkNo',NOW())"); } echo "<h4>You has been successfully added to the walk program</h4>"; } } } } ?> <hr class="hr_blue"/></p><font face="Arial" size="3">Join Walk </font><form method="post" class="addwalkerform" action=""> </font> <fieldset> <label for="MemberRef">MemberRef:</label> <input name="MemberRef" type="text" id="MemberRef" value="<?php echo $_POST['MemberRef']; ?>"/> <span class="redboldtxt"><?php echo "$MemberRef_message";?></fieldset></span> </fieldset> <fieldset> <label for="Password">Password:</label> <input name="Password" type="text" id="Password" value="<?php echo $_POST['Password']; ?>"/> <span class="redboldtxt"><?php echo "$Password_message";?></fieldset></span> <span class="redboldtxt"><?php echo "$Password2_message";?></fieldset></span> <fieldset> <p class="submit"><input type="submit" name="submit" value="Join Walk" /> <span class="redboldtxt"><?php echo "$User_message";?></fieldset></span> <p></p> <span class="redboldtxt"><?php echo "$Walk_message";?></fieldset></span> <span class="redboldtxt"><?php echo "$Add_message";?></fieldset></span> </fieldset> </fieldset> </form>
  5. Im trying to add the current date in a mysql database, but im not sure if im on the right track: Im using the following sql insert statement: mysql_query("INSERT INTO walker (MemberRef, WalkNo, DateJoined) VALUES ('$MemberRef', '$WalkNo', NOW()"); Can i use date(Now) to insert the current date?
  6. I dont need the "Join walk" in, i just want the "WalkNo" that is displayed on the table as the link, sorry for the confusion
  7. I have the link working, but i want the link included within the "WalkNo" column in the table, just not sure how to add it in: <td class="Body"><?php echo $account["WalkNo"]; ?></td> <td class="Body"><?php echo $account["Venue"]; ?></td> <td class="Body"><?php echo $account["WalkDate"]; ?></td> <td class="Body"><?php echo $account["Leader"]; ?></td> <td class="Join"><?php echo "<a href='JoinWalk.php?WalkNo=$WalkNo'>Join Walk</a>"?></p></td> for example: <td class="Body"><?php echo $account["WalkNo"]; "<a href='JoinWalk.php?WalkNo=$WalkNo'>Join Walk</a>" ?></td>
  8. I am trying to add a link in a table that goes to another page: I want to add the href in the line below: <td class="Join"><?php echo "<a href='JoinWalk.php?WalkNo=$WalkNo'>Join Walk</a>"?></p></td> and add it to the following line instead: <td class="Body"><?php echo $account["WalkNo"]; ?></td>
  9. Hey guys thanks for the help really appreciate it
  10. I used this one, pretty easy to use: http://www.php-mysql-tutorial.com/php-mysql-paging.php Hope that helps
  11. I am display records in a table and a using a while loop, the while loop works fine but it wont display the records properly in the table, if the query returns more than one record it displays the first record in the table, the second record is displayed below the table, can anyone help? Code: <?php $WalkNo = $_GET['WalkNo']; $WalkNo = mysql_real_escape_string($WalkNo); $Venue = mysql_real_escape_string($Venue); $WalkDate = mysql_real_escape_string($WalkDate); $Leader = mysql_real_escape_string($Leader); $account = mysql_fetch_array(mysql_query("SELECT * FROM walks WHERE WalkNo='$WalkNo'")); ?> </table> <table class="join" cellspacing="0" width="861"> <tr> <td class="Header">WalkNo</td> <td class="Body"><?php echo $account["WalkNo"]; ?></td> </tr> <tr> <td class="Header">Venue</td> <td class="Body"><?php echo $account["Venue"]; ?></td> </tr> <tr> <td class="Header">WalkDate</td> <td class="Body"><?php echo $account["WalkDate"]; ?></td> </tr> <tr> <td class="Header">Leader</td> <td class="Body"><?php echo $account["Leader"]; ?></td> </tr> </table> <p> <hr class="hr_blue"/></p> <font face="Arial" size="3"> Walk Participants</font> <p></p> <?php $WalkNo = $_GET['WalkNo']; $query = "SELECT w.WalkNo, m.MemberRef, m.Forename, m.Surname, w.DateJoined FROM members m, walker w WHERE w.MemberRef=m.MemberRef AND w.WalkNo='$WalkNo'"; $result = mysql_query($query) or die('Query error!<br />Error:' . mysql_error() . 'Query: <pre>' . $query . '</pre>'); if(mysql_num_rows($result) == 0) { print "No Participants exist"; } else{ ?> <table class="join" cellspacing="0" width="861"> <tr> <td class="Header">WalkNo</td> <td class="Header">Member Ref</td> <td class="Header">Forename</td> <td class="Header">Surname</td> <td class="Header">DateJoined</td> </tr> <?php while ($account = mysql_fetch_assoc($result)) { ?> <tr> <td class="Body"><?php echo $account["WalkNo"]; ?></td> <td class="Body"><?php echo $account["MemberRef"]; ?></td> <td class="Body"><?php echo $account["Forename"]; ?></td> <td class="Body"><?php echo $account["Surname"]; ?></td> <td class="Body"><?php echo $account["DateJoined"]; ?></td> </tr> </table> <?php } ?> <?php if (isset($_POST['submit'])) { $error_stat = 0; $MemberRef_message = ''; $Password_message = ''; $Password2_message = ''; $User_message = ''; $Walk_message = ''; $MemberRef = mysql_real_escape_string(stripslashes($_POST['MemberRef'])); $Password = mysql_real_escape_string(stripslashes($_POST['Password'])); //Error checking // MemberRef Check) if (!$MemberRef) { //Set the error_stat to 1, which means that an error has occurred $error_stat = 1; //Set the message to tell the user to enter a username $MemberRef_message = '*Please enter MemberRef*'; } else if (!ctype_digit($MemberRef)) { $error_stat = 1; $MemberRef_message .= '*MemberRef must be a number*'; } if (!$Password) { //Set the error_stat to 1, which means that an error has occurred $error_stat = 1; //Set the message to tell the user to enter a password $Password_message = '*Please enter a Password*'; } // MemberRef and Password Check if (isset($_POST['submit']) && $error_stat == 0) { $account = mysql_query("SELECT * FROM members WHERE MemberRef='$MemberRef' AND Password='$Password'"); $numrows = mysql_num_rows($account); //get rows returned if($numrows == 0) { $error_stat = 1; $User_message = '*Username and/or Password are invalid*'; } // Walker Check if (isset($_POST['submit']) && $error_stat == 0) { $account = mysql_query("SELECT * FROM walker WHERE MemberRef='$MemberRef' AND WalkNo='$WalkNo'"); $numrows = mysql_num_rows($account); //get rows returned if($numrows == 1) { $error_stat = 1; $Walk_message = '*User is already on walk*'; } } } } ?> <hr class="hr_blue"/></p><font face="Arial" size="3">Join Walk </font><form method="post" class="addwalkerform" action=""> </font> <fieldset> <label for="MemberRef">MemberRef:</label> <input name="MemberRef" type="text" id="MemberRef" value="<?php echo $_POST['MemberRef']; ?>"/> <span class="redboldtxt"><?php echo "$MemberRef_message";?></fieldset></span> </fieldset> <fieldset> <label for="Password">Password:</label> <input name="Password" type="text" id="Password" value="<?php echo $_POST['Password']; ?>"/> <span class="redboldtxt"><?php echo "$Password_message";?></fieldset></span> <span class="redboldtxt"><?php echo "$Password2_message";?></fieldset></span> <fieldset> <p class="submit"><input type="submit" name="submit" value="Join Walk" /> <span class="redboldtxt"><?php echo "$User_message";?></fieldset></span> <p></p> <span class="redboldtxt"><?php echo "$Walk_message";?></fieldset></span> </fieldset> </fieldset> </form> <?php } ?>
  12. Ok i have managed to get it displaying the form if the query return no results in the table about the form. I have a problem with the while loop, if there is more than 1 record returned in doesnt put the record into the table, it puts it below it for some reason. The code is now: <?php $WalkNo = $_GET['WalkNo']; $WalkNo = mysql_real_escape_string($WalkNo); $Venue = mysql_real_escape_string($Venue); $WalkDate = mysql_real_escape_string($WalkDate); $Leader = mysql_real_escape_string($Leader); $account = mysql_fetch_array(mysql_query("SELECT * FROM walks WHERE WalkNo='$WalkNo'")); ?> </table> <table class="join" cellspacing="0" width="861"> <tr> <td class="Header">WalkNo</td> <td class="Body"><?php echo $account["WalkNo"]; ?></td> </tr> <tr> <td class="Header">Venue</td> <td class="Body"><?php echo $account["Venue"]; ?></td> </tr> <tr> <td class="Header">WalkDate</td> <td class="Body"><?php echo $account["WalkDate"]; ?></td> </tr> <tr> <td class="Header">Leader</td> <td class="Body"><?php echo $account["Leader"]; ?></td> </tr> </table> <p> <hr class="hr_blue"/></p> <font face="Arial" size="3"> Walk Participants</font> <p></p> <?php $WalkNo = $_GET['WalkNo']; $query = "SELECT w.WalkNo, m.MemberRef, m.Forename, m.Surname, w.DateJoined FROM members m, walker w WHERE w.MemberRef=m.MemberRef AND w.WalkNo='$WalkNo'"; $result = mysql_query($query) or die('Query error!<br />Error:' . mysql_error() . 'Query: <pre>' . $query . '</pre>'); if(mysql_num_rows($result) == 0) { print "No Participants exist"; } else{ ?> <table class="join" cellspacing="0" width="861"> <tr> <td class="Header">WalkNo</td> <td class="Header">Member Ref</td> <td class="Header">Forename</td> <td class="Header">Surname</td> <td class="Header">DateJoined</td> </tr> <?php while ($account = @mysql_fetch_assoc($result)) { ?> <tr> <td class="Body"><?php echo $account["WalkNo"]; ?></td> <td class="Body"><?php echo $account["MemberRef"]; ?></td> <td class="Body"><?php echo $account["Forename"]; ?></td> <td class="Body"><?php echo $account["Surname"]; ?></td> <td class="Body"><?php echo $account["DateJoined"]; ?></td> </tr> </table> <?php } } ?> <?php if (isset($_POST['submit'])) { $error_stat = 0; $MemberRef_message = ''; $Password_message = ''; $Password2_message = ''; $User_message = ''; $Walk_message = ''; $MemberRef = mysql_real_escape_string(stripslashes($_POST['MemberRef'])); $Password = mysql_real_escape_string(stripslashes($_POST['Password'])); //Error checking // MemberRef Check) if (!$MemberRef) { //Set the error_stat to 1, which means that an error has occurred $error_stat = 1; //Set the message to tell the user to enter a username $MemberRef_message = '*Please enter MemberRef*'; } else if (!ctype_digit($MemberRef)) { $error_stat = 1; $MemberRef_message .= '*MemberRef must be a number*'; } if (!$Password) { //Set the error_stat to 1, which means that an error has occurred $error_stat = 1; //Set the message to tell the user to enter a password $Password_message = '*Please enter a Password*'; } // MemberRef and Password Check if (isset($_POST['submit']) && $error_stat == 0) { $account = mysql_query("SELECT * FROM members WHERE MemberRef='$MemberRef' AND Password='$Password'"); $numrows = mysql_num_rows($account); //get rows returned if($numrows == 0) { $error_stat = 1; $User_message = '*Username and/or Password are invalid*'; } // Walker Check if (isset($_POST['submit']) && $error_stat == 0) { $account = mysql_query("SELECT * FROM walker WHERE MemberRef='$MemberRef' AND WalkNo='$WalkNo'"); $numrows = mysql_num_rows($account); //get rows returned if($numrows == 1) { $error_stat = 1; $Walk_message = '*User is already on walk*'; } } } } ?> <hr class="hr_blue"/></p><font face="Arial" size="3">Join Walk </font><form method="post" class="addwalkerform" action=""> </font> <fieldset> <label for="MemberRef">MemberRef:</label> <input name="MemberRef" type="text" id="MemberRef" value="<?php echo $_POST['MemberRef']; ?>"/> <span class="redboldtxt"><?php echo "$MemberRef_message";?></fieldset></span> </fieldset> <fieldset> <label for="Password">Password:</label> <input name="Password" type="text" id="Password" value="<?php echo $_POST['Password']; ?>"/> <span class="redboldtxt"><?php echo "$Password_message";?></fieldset></span> <span class="redboldtxt"><?php echo "$Password2_message";?></fieldset></span> <fieldset> <p class="submit"><input type="submit" name="submit" value="Join Walk" /> <span class="redboldtxt"><?php echo "$User_message";?></fieldset></span> <p></p> <span class="redboldtxt"><?php echo "$Walk_message";?></fieldset></span> </fieldset> </fieldset> </form>
×
×
  • 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.