psychowolvesbane
Members-
Posts
204 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
psychowolvesbane's Achievements
Member (2/5)
0
Reputation
-
[SOLVED] Error searching help
psychowolvesbane replied to psychowolvesbane's topic in PHP Coding Help
Okay I've solved the problem, it looks like I was using a JavaScript only function for checking the string length of a variable so it caused some problems, now I've used the isset($PostCode{8}) on the elseif line and it works perfectly. -
[SOLVED] Error searching help
psychowolvesbane replied to psychowolvesbane's topic in PHP Coding Help
Ah thanks I'm now getting: Fatal error: Call to undefined function: length() in /usr/home/awccloth/public_html/admin/add_campus_details_form.php on line 158 which is part of this validation: if(empty($PostCode)) { $Errors++; $Err9 = "<span class=\"errmsg\">! </span>"; $MsgPostCode = "<span class=\"errmsg\">Please Enter the Post Code</span><br>"; } elseif((length($PostCode) !== 7) || (length($PostCode) !== 6)) { $Errors++; $Err9 = "<span class='errmsg'>! </span>"; $MsgPostCode = "<span class='errmsg'>Please enter a valid post code </span><br>"; } else { $MsgPostCode=""; $Err9 = ""; } -
[SOLVED] Error searching help
psychowolvesbane replied to psychowolvesbane's topic in PHP Coding Help
Okay the page loads fine with the form and everything, then when I press submit and I get past the JavaScript validation check the page reloads and it's just a blank white screen with no error messages, I spent a little while to determine it was the PHP validation section causing the problem but I can't see anything out of place, even compared to my other forms. All my form values are fine and work as they should be. P.S. I have already used error_report(E_ALL); but it didn't turn up anything wrong. -
Hey I've had this form that used to work until very recently, I'm pretty sure I've not made any changes to the problem area since it used to work but for some reason it's causing problems. The problem is the PHP form validation from lines 26 to 165 of the code below: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <?php session_start(); include "connect_details.php"; $Submit = $_POST['SubmitB']; if($_POST['SubmitB'] == "Submit") { $Campus = addslashes($_POST['Campus']); $CampusEmail = $_POST['CampusEmail']; $ConfirmEmail = $_POST['ConfirmEmail']; $TelNo = $_POST['TelNo']; $Add1 = addslashes($_POST['Add1']); $Add2 = addslashes($_POST['Add2']); $Add3 = addslashes($_POST['Add3']); $Town = addslashes($_POST['Town']); $County = addslashes($_POST['County']); $PostCode = addslashes($_POST['PostCode']); $Errors = "0"; // This section is causing errors when it used to work and works fine without it, but I need to keep the PHP validation. if(empty($Campus)) { $Errors++; $Err1 = "<span class='errmsg'>! </span>"; $MsgCampus = "<span class='errmsg'>Please Enter the Campus Name</span><br>"; } else { $MsgCampus=""; $Err1 = ""; } if($CampusEmail !== $ConfirmEmail) { $Errors++; $Err2 = "<span class='errmsg'>! </span>"; $MsgCampusEmail = "<span class='errmsg'>The Email Addresses do not match please re-confirm them</span><br>"; } else { if(empty($CampusEmail)) { $Errors++; $Err2 = "<span class='errmsg'>! </span>"; $MsgCampusEmail = "<span class='errmsg'>Please Enter a Campus Email Address</span><br>"; } elseif(!preg_match('/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $CampusEmail)) { $Errors++; $Err2 = "<span class='errmsg'>! </span>"; $MsgCampusEmail = "<span class='errmsg'>Please Enter a valid Campus Email Address</span><br>"; } else { $MsgCampusEmail=""; $Err2 = ""; } if(empty($ConfirmEmail)) { $Errors++; $Err3 = "<span class='errmsg'>! </span>"; $MsgConfirmEmail = "<span class='errmsg'>Please Enter a Confirmation Email Address</span><br>"; } elseif(!preg_match('/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $ConfirmEmail)) { $Errors++; $Err3 = "<span class='errmsg'>! </span>"; $MsgConfirmEmail = "<span class='errmsg'>Please Enter a valid Confirmation Email Address</span><br>"; } else { $MsgConfirmEmail=""; $Err3 = ""; } } if(empty($TelNo)) { $Errors++; $Err4 = "<span class='errmsg'>! </span>"; $MsgTelNo = "<span class='errmsg'>Please Enter the Telephone Number!</span><br>"; } elseif(is_numeric($TelNo) == false) { $Errors++; $Err4 = "<span class='errmsg'>! </span>"; $MsgTelNo = "<span class='errmsg'>That is not a valid Telephone Number!</span><br>"; } else { $MsgTelNo=""; $Err4 = ""; } if(empty($Add1)) { $Errors++; $Err5 = "<span class='errmsg'>! </span>"; $MsgAdd1 = "<span class='errmsg'>Please Enter the Address Line 1</span><br>"; } else { $MsgAdd1=""; $Err5 = ""; } if(empty($Add2)) { $Errors++; $Err6 = "<span class='errmsg'>! </span>"; $MsgAdd2 = "<span class='errmsg'>Please Enter the Address Line 2</span><br>"; } else { $MsgAdd2=""; $Err6 = ""; } if(empty($Town)) { $Errors++; $Err7 = "<span class='errmsg'>! </span>"; $MsgTown = "<span class='errmsg'>Please Enter the Town</span><br>"; } else { $MsgTown=""; $Err7 = ""; } if(empty($County)) { $Errors++; $Err8 = "<span class='errmsg'>! </span>"; $MsgCounty = "<span class='errmsg'>Please Enter the County</span><br>"; } else { $MsgCounty=""; $Err8 = ""; } if(empty($PostCode)) { $Errors++; $Err9 = "<span class=\"errmsg\">! </span>"; $MsgPostCode = "<span class=\"errmsg\">Please Enter the Post Code</span><br>"; } elseif((length($PostCode) !== 7) || (length($PostCode) !== 6)) { $Errors++; $Err9 = "<span class='errmsg'>! </span>"; $MsgPostCode = "<span class='errmsg'>Please enter a valid post code </span><br>"; } else { $MsgPostCode=""; $Err9 = ""; } // End of section if($Errors==0) { $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); $rs1 = mysql_query("SELECT * FROM Campus",$conn) or die(mysql_error()); $NumberOfRecords = mysql_num_rows($rs1); $CampusID = "Campus".($NumberOfRecords+1); $X = 1; while($OkCampusID == false) { $rs2 = mysql_query("SELECT CampusID FROM Campus WHERE CampusID='$CampusID'",$conn) or die(mysql_error()); if(mysql_num_rows($rs2)==1) { $OkCampusID = false; $CampusID = "Campus".$X; } else { $OkCampusID = true; } $X++; } $rsNew = mysql_query("INSERT INTO Campus (CampusID, Campus, CampusEmail, TelNo, Add1, Add2, Add3, Town, County, PostCode) VALUES('$CampusID','$Campus','$CampusEmail','$TelNo','$Add1','$Add2','$Add3','$Town','$County','$PostCode')",$conn) or die(mysql_error()); if(mysql_affected_rows($conn) == 1) { $_SESSION['NewAction'] = "Added"; } elseif(mysql_affected_rows($conn) == 0) { $_SESSION['NewAction'] = "NotAdded"; } mysql_close($conn); header("Location:display_campus_details.php?Action=Edit"); } } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="keywords" content="Abingdon College, Witney College, clothing, Clothing Line, hats, bags, t-shirts, shirts, vests, jackets"> <meta name="description" content="Clothing Line"> <meta name="author" content="Adam Compton"> <title>Clothing Line - New Campus Form</title> <link href="stylesheetCL.css" rel="stylesheet"> <?php require('jscript.inc'); if(($_SESSION['User_Type'] == "Student") || ($_SESSION['User_Type'] == "")) { header("Location:../index.php"); } ?> <script language='JavaScript' type='text/JavaScript'> <!-- function IsNumeric(strString) { var strValidChars = "0123456789-"; var strChar; var Result = true; if (strString.length == 0) return false; for (i = 0; i < strString.length && Result == true; i++) { strChar = strString.charAt(i); if (strValidChars.indexOf(strChar) == -1) { Result = false; } } return Result; } function Validate(f) { return (ValidateValues(f)==0 ? true : false ); } function ValidateValues(f) { var Errors = 0 if((document.AddCampus.Campus.value+'').length<1) { Errors++ document.getElementById('mySpan1a').style.display='block'; document.getElementById('mySpan1a').innerHTML='Please Enter a Campus Name!'; document.getElementById('mySpan1b').style.display='inline'; document.getElementById('mySpan1b').innerHTML='! '; } else { document.getElementById('mySpan1a').style.display='none'; document.getElementById('mySpan1a').innerHTML=''; document.getElementById('mySpan1b').style.display='none'; document.getElementById('mySpan1b').innerHTML=''; } if(document.AddCampus.CampusEmail.value !== document.AddCampus.ConfirmEmail.value) { Errors++ document.getElementById('mySpan2a').style.display='block'; document.getElementById('mySpan2a').innerHTML='The Email Addresses do not match, please re-confirm them!'; document.getElementById('mySpan2b').style.display='inline'; document.getElementById('mySpan2b').innerHTML='! '; document.getElementById('mySpan2d').style.display='inline'; document.getElementById('mySpan2d').innerHTML='! '; } else { if(document.AddCampus.CampusEmail.value =="") { Errors++ document.getElementById('mySpan2a').style.display='block'; document.getElementById('mySpan2a').innerHTML='Please Enter an Email Address!'; document.getElementById('mySpan2b').style.display='inline'; document.getElementById('mySpan2b').innerHTML='! '; } else if(!document.AddCampus.CampusEmail.value.match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/)) { Errors++ document.getElementById('mySpan2a').style.display='block'; document.getElementById('mySpan2a').innerHTML='Please Enter a Valid Email Address!'; document.getElementById('mySpan2b').style.display='inline'; document.getElementById('mySpan2b').innerHTML='! '; } else { document.getElementById('mySpan2a').style.display='none'; document.getElementById('mySpan2a').innerHTML=''; document.getElementById('mySpan2b').style.display='none'; document.getElementById('mySpan2b').innerHTML=''; } if(document.AddCampus.ConfirmEmail.value =="") { Errors++ document.getElementById('mySpan2c').style.display='block'; document.getElementById('mySpan2c').innerHTML='Please Enter an Confirmation Email Address!'; document.getElementById('mySpan2d').style.display='inline'; document.getElementById('mySpan2d').innerHTML='! '; } else if(!document.AddCampus.ConfirmEmail.value.match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/)) { Errors++ document.getElementById('mySpan2c').style.display='block'; document.getElementById('mySpan2c').innerHTML='Please Enter a Valid Confirmation Email Address!'; document.getElementById('mySpan2d').style.display='inline'; document.getElementById('mySpan2d').innerHTML='! '; } else { document.getElementById('mySpan2c').style.display='none'; document.getElementById('mySpan2c').innerHTML=''; document.getElementById('mySpan2d').style.display='none'; document.getElementById('mySpan2d').innerHTML=''; } } if((document.AddCampus.TelNo.value+'').length<0) { Errors++; document.getElementById('mySpan3a').style.display='block'; document.getElementById('mySpan3a').innerHTML='Please Enter the Telephone Number!'; document.getElementById('mySpan3b').style.display='inline'; document.getElementById('mySpan3b').innerHTML='! '; } else if((document.AddCampus.TelNo.value+'').length<11) { Errors++; document.getElementById('mySpan3a').style.display='block'; document.getElementById('mySpan3a').innerHTML='Please Enter a Valid Telephone Number!'; document.getElementById('mySpan3b').style.display='inline'; document.getElementById('mySpan3b').innerHTML='! '; } else if(IsNumeric(document.AddCampus.TelNo.value) == false) { Errors++; document.getElementById('mySpan3a').style.display='block'; document.getElementById('mySpan3a').innerHTML='Please Enter a valid Telephone Number!'; document.getElementById('mySpan3b').style.display='inline'; document.getElementById('mySpan3b').innerHTML='! '; } else { document.getElementById('mySpan3a').style.display='none'; document.getElementById('mySpan3a').innerHTML=''; document.getElementById('mySpan3b').style.display='none'; document.getElementById('mySpan3b').innerHTML=''; } if((document.AddCampus.Add1.value+'').length<1) { Errors++; document.getElementById('mySpan4a').style.display='none'; document.getElementById('mySpan4a').innerHTML='Please Enter Address Line 1!'; document.getElementById('mySpan4b').style.display='inline'; document.getElementById('mySpan4b').innerHTML='! '; } else { document.getElementById('mySpan4a').style.display='none'; document.getElementById('mySpan4a').innerHTML=''; document.getElementById('mySpan4b').style.display='none'; document.getElementById('mySpan4b').innerHTML=''; } if((document.AddCampus.Add2.value+'').length<1) { Errors++; document.getElementById('mySpan5a').style.display='none'; document.getElementById('mySpan5a').innerHTML='Please Enter Address Line 2!'; document.getElementById('mySpan5b').style.display='inline'; document.getElementById('mySpan5b').innerHTML='! '; } else { document.getElementById('mySpan5a').style.display='none'; document.getElementById('mySpan5a').innerHTML=''; document.getElementById('mySpan5b').style.display='none'; document.getElementById('mySpan5b').innerHTML=''; } if((document.AddCampus.Town.value+'').length<1) { Errors++ document.getElementById('mySpan6a').style.display='block'; document.getElementById('mySpan6a').innerHTML='Please Enter the Town!'; document.getElementById('mySpan6b').style.display='inline'; document.getElementById('mySpan6b').innerHTML='! '; } else { document.getElementById('mySpan6a').style.display='none'; document.getElementById('mySpan6a').innerHTML=''; document.getElementById('mySpan6b').style.display='none'; document.getElementById('mySpan6b').innerHTML=''; } if((document.AddCampus.County.value+'').length<1) { Errors++; document.getElementById('mySpan7a').style.display='block'; document.getElementById('mySpan7a').innerHTML='Please Enter the County!'; document.getElementById('mySpan7b').style.display='inline'; document.getElementById('mySpan7b').innerHTML='! '; } else { document.getElementById('mySpan7a').style.display='none'; document.getElementById('mySpan7a').innerHTML=''; document.getElementById('mySpan7b').style.display='none'; document.getElementById('mySpan7b').innerHTML=''; } if((document.AddCampus.PostCode.value+'').length<1) { Errors++; document.getElementById('mySpan8a').style.display='block'; document.getElementById('mySpan8a').innerHTML='Please Enter the Post Code!'; document.getElementById('mySpan8b').style.display='inline'; document.getElementById('mySpan8b').innerHTML='! '; } else { document.getElementById('mySpan8a').style.display='none'; document.getElementById('mySpan8a').innerHTML=''; document.getElementById('mySpan8b').style.display='none'; document.getElementById('mySpan8b').innerHTML=''; } return Errors; } //--> </script> </head> <body> <div class="MainContainer"> <?php require('header.inc'); require('menu.inc') ?> <div class="DivMain"> <span class="head1">New Campus Form</span><br> <span class="errmsg">All fields marked with an * are required</span><br><br> <?php echo $MsgCampus; echo $MsgCampusEmail; echo $MsgConfirmEmail; echo $MsgTelNo; echo $MsgAdd1; echo $MsgAdd2; echo $MsgTown; echo $MsgCounty; echo $MsgPostCode; ?> <span id="mySpan1a" class="mySpan1a"><br></span> <span id="mySpan2a" class="mySpan2a"><br></span> <span id="mySpan2c" class="mySpan2c"><br></span> <span id="mySpan3a" class="mySpan3a"><br></span> <span id="mySpan4a" class="mySpan4a"><br></span> <span id="mySpan5a" class="mySpan5a"><br></span> <span id="mySpan6a" class="mySpan6a"><br></span> <span id="mySpan7a" class="mySpan7a"><br></span> <span id="mySpan8a" class="mySpan8a"><br></span> <br> <form method="POST" action="add_campus_details_form.php" name="AddCampus" onSubmit="return Validate(this);"> <table style="width: auto; position: absolute;"> <tr><td><?php echo $Err1?><span id="mySpan1b" class="mySpan1b"></span><span class="head4">Campus Name:</span><span class="errmsg"> *</span></td> <td width="300"><label><input type="text" size="33" name="Campus" maxlength="30" value="<?php echo $Campus?>"/></label> </td></tr> <tr><td><?php echo $Err2?><span id="mySpan2b" class="mySpan2b"></span><span class="head4">Campus Email:</span><span class="errmsg"> *</span></td> <td width="300"><label><input type="text" size="55" maxlength="50" name="CampusEmail" value="<?php echo $CampusEmail?>"/></label> </td></tr> <tr><td><?php echo $Err3?><span id="mySpan2d" class="mySpan2d"></span><span class="head4">Confirm Email:</span><span class="errmsg"> *</span></td> <td width="300"><label><input type="text" size="55" maxlength="50" name="ConfirmEmail" value="<?php echo $ConfirmEmail?>"/> </label></td></tr><tr></tr> <tr><td><?php echo $Err4?><span id="mySpan3b" class="mySpan3b"></span><span class="head4">Telephone No:</span><span class="errmsg"> *</span></td> <td width="300"><label><input type="text" size="15" maxlength="15" name="TelNo" value="<?php echo $TelNo?>"/></label><span class="normal"> (No spaces)</span> </td></tr> <tr><td><?php echo $Err5?><span id="mySpan4b" class="mySpan4b"></span><span class="head4">Address 1:</span><span class="errmsg"> *</span></td> <td width="300"><label><input type="text" size="33" name="Add1" maxlength="30" value="<?php echo $Add1?>"/></label> </td></tr> <tr><td><?php echo $Err6?><span id="mySpan5b" class="mySpan5b"></span><span class="head4">Address 2:</span><span class="errmsg"> *</span></td> <td width="300"><label><input type="text" size="33" name="Add2" maxlength="30" value="<?php echo $Add2?>"/></label> </td></tr> <tr><td><span class="head4">Address 3:</span><br></td> <td width="300"><label><input type="text" size="33" name="Add3" maxlength="30" value="<?php echo $Add3?>"/></label> </td></tr> <tr><td><?php echo $Err7?><span id="mySpan6b" class="mySpan6b"></span><span class="head4">Town:</span><span class="errmsg"> *</span></td> <td width="300"><label><input type="text" size="33" name="Town" maxlength="30" value="<?php echo $Town?>"/></label> </td></tr> <tr><td><?php echo $Err8?><span id="mySpan7b" class="mySpan7b"></span><span class="head4">County:</span><span class="errmsg"> *</span></td> <td width="300"><label><input type="text" size="20" name="County" maxlength="20" value="<?php echo $County?>"/></label> </td></tr> <tr><td><?php echo $Err9?><span id="mySpan8b" class="mySpan8b"></span><span class="head4">Post Code:</span><span class="errmsg"> *</span></td> <td width="300"><label><input type="text" size="7" maxlength="7" name="PostCode" value="<?php echo $PostCode?>"/></label><span class="normal"> (No spaces)</span> </td></tr> <tr><td> <input type="submit" name="SubmitB" class="buttonS" style="overflow:visible; width:auto" value="Submit" onMouseOver="OverMouse(this)"; onMouseOut="OutMouse(this)"/> <input type="reset" name="ResetB" class="buttonS" style="overflow:visible; width:auto" value="Reset" onMouseOver="OverMouse(this)"; onMouseOut="OutMouse(this)"/> </td></tr> <tr></tr> <tr><td><a href="display_campus_details.php?Action=Edit">Back to Edit Campus Details List</a></td></tr> </table> </form> </div> </div> </body> </html> If anyone can tell me why it's happening I'd be greatly appreciated.
-
Edit: Okay I did a little bit of searching for the SQL Date_Sub() function and came across a solution: $sql = "SELECT * FROM UserAccount WHERE Status='0' AND DateOfReg <= {fn DATE_SUB({fn CURDATE()}, INTERVAL 14 DAY)}"; Thanks anyway for trying!
-
Yeah, sorry it's 2008-09-27 (Y-m-d).
-
Hi, I have a user list where I sort between various criteria from the database, one of which is to see which Inactive users haven't activated their account after 14 days, the date of registration is also a field in the table for comparison. I have tried to select only those users who haven't activated after that time period but it just brings up all the inactive users instead of a few who registered more than 2 weeks ago. Here is the code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <?php session_start(); if(isset($_POST['DelYes'])) { } ?> <html> <head> <title>Clothing Line</title> <link href="stylesheetCL.css" rel="stylesheet"> <?php require('jscript.inc'); if(($_SESSION['User_Type'] == "Student") || ($_SESSION['User_Type'] == "")) { header("Location:../index.php"); } else { $Action = $_GET['Action']; $NewAction = $_SESSION['NewAction']; if ($Action == "") { header("Location:admin.php"); } $Sort = $_GET['Sort']; if($Sort =="") { $Sort = "All"; } } ?> </head> <body> <div class="MainContainer"> <?php require('header.inc'); include "connect_details.php"; require('menu.inc'); ?> <div class="DivMain"> <?php $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); if($Sort == "All") { $Category = "All"; $sql = "SELECT * FROM UserAccount"; } elseif($Sort == "Admins") { $Category = "Admins"; $sql = "SELECT * FROM UserAccount WHERE AccountType='Admin'"; } elseif($Sort == "Students") { $Category = "Students"; $sql = "SELECT * FROM UserAccount WHERE AccountType='Student'"; } elseif($Sort == "Inactive") { $Category = "Inactive"; $sql = "SELECT * FROM UserAccount WHERE Status='0'"; } elseif($Sort == "Unactivated") { $Category = "Unactived"; //THIS IS THE PROBLEM######### $sql = "SELECT * FROM UserAccount WHERE Status='0' AND DATE_SUB(NOW(), INTERVAL 14 DAY) >= DateOfReg "; //THIS IS THE PROBLEM######### } if ($Action == "Edit") { echo"<span class=\"head3\">List of Users - Category: ".$Category."</span><br><br> <a href=\"display_user_details.php?Action=Edit&Sort=All\">All Users</a> | <a href=\"display_user_details.php?Action=Edit&Sort=Admins\">Admins</a> | <a href=\"display_user_details.php?Action=Edit&Sort=Students\">Students</a> | <a href=\"display_user_details.php?Action=Edit&Sort=Inactive\">Inactive Users</a> | <a href=\"display_user_details.php?Action=Edit&Sort=Unactivated\">Overdue Activated Users</a><br><br>"; $rs = mysql_query($sql, $conn); if(mysql_affected_rows($conn) == 0) { echo"<span class='errmsg'>There are no users in this category</span><br><br>"; } else { echo"<span class=\"head4\">Click on one to edit</span><br><br> <table border=\"0\" cellpadding=\"3\"><tr> <th>Surname</th> <th>Email</th> <th>Campus</th> <th>Date Of Reg</th> <th>User Type</th> <th>Status</th> </tr>"; while($row = mysql_fetch_array($rs)) { $UserID = $row['UserID']; $Surname = $row['Surname']; $Email = $row['Email']; $Campus = $row['Campus']; $DateOfReg = $row['DateOfReg']; $UserType = $row['AccountType']; $Status = $row['Status']; $Activity = ""; if($Status == 0) { $Activity = "Inactive"; } else { $Activity = "Active"; } echo "<tr style=\"color:#E61732; line-height:8pt\" onMouseOver=\"this.style.backgroundColor='#FF7777';this.style.color='black'; this.style.cursor='pointer'\"onMouseOut=\"this.style.backgroundColor='white';this.style.color='#E61732'\" onClick=\"location.href='edit_user_details_form.php?UserID=$UserID'\"> <td class=\"tdcenter\">$Surname</td> <td class=\"tdcenter\">$Email</td> <td class=\"tdcenter\">$Campus</td> <td class=\"tdcenter\">$DateOfReg</td> <td class=\"tdcenter\">$UserType</td> <td class=\"tdcenter\">$Activity</td> </tr>"; } mysql_close($conn); echo"</table>"; } } elseif($Action == "Delete") { echo"<span class=\"head3\">List of Users - Category: ".$Category."</span><br><br>"; echo"<a href=\"display_user_details.php?Action=Delete&Sort=All\">All Users</a> | <a href=\"display_user_details.php?Action=Delete&Sort=Students\">Students</a> | <a href=\"display_user_details.php?Action=Delete&Sort=Admins\">Admins</a> | <a href=\"display_user_details.php?Action=Delete&Sort=Inactive\">Inactive Users</a> | <a href=\"display_user_details.php?Action=Delete&Sort=Unactivated\">Overdue Activated Users</a><br><br>"; $rs = mysql_query($sql, $conn); if(mysql_affected_rows($conn) == 0) { echo"<span class=\"errmsg\">There are users in this category</span><br><br>"; } else { echo"<span class=\"head4\">Click on one to delete</span><br><br> <table border=\"0\" cellpadding=\"3\"><tr> <th>Surname</th> <th>Email</th> <th>Campus</th> <th>Date Of Reg</th> <th>User Type</th> <th>Status</th> </tr>"; while($row = mysql_fetch_array($rs)) { $UserID = $row['UserID']; $Surname = $row['Surname']; $Email = $row['Email']; $Campus = $row['Campus']; $DateOfReg = $row['DateOfReg']; $UserType = $row['AccountType']; $Status = $row['Status']; $Activity = ""; if($Status == 0) { $Activity = "Inactive"; } else { $Activity = "Active"; } echo "<tr style=\"color:#E61732; line-height:8pt\" onMouseOver=\"this.style.backgroundColor='#FF7777';this.style.color='black'; this.style.cursor='pointer'\"onMouseOut=\"this.style.backgroundColor='white';this.style.color='#E61732'\" onClick=\"if(confirm('Are you sure you wish to delete this user?'))window.location.href='delete_user.php?UserID=$UserID'\"> <td class=\"tdcenter\">$Surname</td> <td class=\"tdcenter\">$Email</td> <td class=\"tdcenter\">$Campus</td> <td class=\"tdcenter\">$DateOfReg</td> <td class=\"tdcenter\">$UserType</td> <td class=\"tdcenter\">$Activity</td> </tr>"; } mysql_close($conn); echo"</table>"; } } if($Sort == "Unactivated") { echo" <br><span class=\"head4\">All of the above users have not activated their account in the alloted 2 weeks, do you wish to remove them?</span> <form method=\"post\" name=\"DeleteUnactivated\" action=\"display_user_details.php?Action=$Action\"> <input type=\"submit\" name=\"DelYes\" class=\"buttonS\" style=\"overflow:visible; width:auto\" value=\"Yes\" onMouseOver=\"OverMouse(this)\"; onMouseOut=\"OutMouse(this)\"/>"; } if($NewAction == "Added") { echo"<br><div style='position:relative; top:100x; left:0px; width:300px'> <span class='head4'>User successfully Added!</span></div>"; } elseif($NewAction == "NotAdded") { echo"<br><div style='position:relative; top:100x; left:0px; width:300px'> <span class='head4'>User could not be Added!</span></div>"; } if($NewAction == "Edited") { echo"<br><div style='position:relative; top:100x; left:0px; width:300px'> <span class='head4'>User successfully Edited!</span></div>"; } elseif($NewAction == "NotEdited") { echo"<br><div style='position:relative; top:100x; left:0px; width:300px'> <span class='head4'>User could not be Edited!</span></div>"; } if($NewAction == "Deleted") { echo"<br><div style='position:relative; top:100x; left:0px; width:300px'> <span class='head4'>User successfully Deleted!</span></div>"; } elseif($NewAction == "NotDeleted") { echo"<br><div style='position:relative; top:100x; left:0px; width:300px'> <span class='head4'>User could not be Deleted!</span></div>"; } echo"<br><br><a href=\"admin.php\">Back to Admin Menu</a>"; unset($_SESSION['NewAction']); ?> </div> </div> </body> </html>
-
The only thing I can see is: $query = "select * from school_data where school_district = '".$selected_district."'"; should be: $query = "select * from school_data where school_district = '$selected_district'";
-
I just noticed something when browsing through you're form coding, on each form input you didn't use value=\"\" even when you paused the echo to place the php variable in, so you must have forgotten that. Although it still seems to post the other info fine except for the id, but give it a shot at least, plus this is how you're form inputs should look like anyway so I'd recommend keeping it. <?php echo "<form method=\"post\" action=\"update_user.php\" id=\"user_update\" name=\"user_update\">"; echo "<p>"; echo "<label for=\"id\">ID:</label><input type=\"text\" disabled=\"disabled\" name=\"id\" id=\"id\" value=\"" . $row['id'] . "\">"; echo "</p>"; echo "<p>"; echo "<label for=\"username\">Username:</label><input type=\"text\" disabled=\"disabled\" name=\"username\" id=\"username\" value=\"" . $row['username'] . "\">"; echo "</p>"; echo "<p>"; echo "<label for=\"name\">First Name:</label><input type=\"text\" name=\"name\" id=\"name\" value=\"" . $row['name'] . "\">"; echo "</p>"; echo "<p>"; echo "<label for=\"surname\">Surname:</label><input type=\"text\" name=\"surname\" id=\"surname\" value=\"" . $row['surname'] . "\">"; echo "</p>"; echo "<p>"; echo "<label for=\"email\">E-mail:</label><input type=\"text\" name=\"email\" id=\"email\" value=\"" . $row['email'] . "\">"; echo "</p>"; echo "<p>"; echo "<label for=\"password\">Password:</label><input type=\"password\" name=\"password\" id=\"password\" onKeyUp=\"passwordStrength(this.value)\" value=\"" . $row['password'] . "\">"; echo "</p>"; echo "<p>"; echo "<label for=\"passconf\">Confirm Password:</label><input type=\"password\" name=\"passconf\" id=\"passconf\" value=\"" . $row['password'] . "\">"; echo "</p>"; echo "<p>"; echo "<label for=\"passwordStrength\">Password Strength</label>"; echo "<div id=\"passwordDescription\">Password not entered</div>"; echo "<div id=\"passwordStrength\" class=\"strength0\"></div>"; echo "</p>"; echo "<p>"; echo "<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Update\">\n"; echo "</p>"; echo "</form>"; ?>
-
So what you can do is place userId into a hidden field within the form to send that information through the POST. P.S. You don't need to use concatenation with this: WHERE `id`='".$id."', WHERE `id`='$id' would be just fine unless you planned to add some non-variable onto the Id.
-
With the Array you need to use: $name = $array['Name']; (or whatever field name it is) $email = $array['Email']; $location = $array['Location']; BTW with an array it would actually start at 0 instead of 1, so 0,1,2 not 1,2,3.
-
<?php $text = 'Some content;?> [phpcode]<?php echo $test; ?>[/phpcode] some content [phpcode]<?php echo $test; ?>[/phpcode] <?php $text = preg_replace('/\[phpcode\](.*?)\[\/phpcode\]/ie', 'highlight_string(\'$1\', TRUE)', $text); echo $text; ?>
-
[SOLVED] limit mysql_query amount
psychowolvesbane replied to DeanWhitehouse's topic in PHP Coding Help
Use a counter variable in your while loop and increment it for each loop: if($counter%3==0&&$counter!=0) echo"</tr><tr>"; Use this for the incrementing: ++$counter; -
Just curious, what's the purpose of checking for a numeric value? mysql_real_escape_string() won't do anything to a number anyway, does it? Perhaps he just uses it on all his inputs just in case.
-
select subid from pay_code where mincost<'300000' and mode1='rent' order by subid desc limit 1; You have too many 0's, if you want 7 you only need 30K not 300K.