PHP - Check Box
Suppose i have a table with around 10 entries in which one column contains the id and the second column contains a checkbox...
If a checkbox a selected and the button (below the table) is pressed then i want to delete the columns corresponding the checked checkboxes.... I am not getting how sgould i pass the get variable on the link of the button??? -Pranshu Agrawal pranshu.a.11@gmail.com Similar TutorialsHello, I have created a little voting script for my site. The insertion code into the MySQL databse when they vote is very simple: $ipaddress = addslashes($_POST['ipaddress']); $theid = addslashes($_POST['theid']); $gamert = addslashes($_POST['gamert']); $serveron = addslashes($_POST['serveron']); $db = mysql_connect("localhost", "username", "password"); mysql_select_db("thedb",$db); mysql_query ("INSERT INTO voting (theid,ipaddress,gamert,serveron2) VALUES ('$theid','$ipaddress','$gamert','$serveron') "); Obviously I only want them to be able to vote once. What is the best way to do a check of the IPs already in the database and check against theirs before submitting? Thanks. Hello their, I'm wanting to use PHP to check to see if a username and password match a remote RDP server. The reason I ask is because I want to verify that the information the user is giving is correct. I'm looking though LDAP but I have no idea what I'm looking for. To recap, I would like to login to a RDP server and return a result based on if it completed. Thank-you for reading Paul P.S Sorry for the bad English, I seemed to forgot how to spell some words and have had to replace them with longer sentences ok so i can get this to work so i want to check if there is a video on inside my db if there is no video and nothing happens but if there is i want it to echo video Code: [Select] <?php if($video == ""){ }else{ echo "VIDEO"; } ?> I am unable to execute mysql_num_rows properly in this program. Code: [Select] <?php $link=mysql_connect("localhost","root",""); $db = mysql_select_db("myDB",$link); $result = mysql_query("SELECT * FROM jobs WHERE jobType=abc"); $num = mysql_num_rows($result); echo "Found $num records"; ?> error is mysql_num_rows() expects parameter 1 to be resource Hey, I'm trying to check if a username is unique, but for some reason none of the methods that I've looked up seem to work. I'm aiming for the code to check if a username is unique, and if get the user to input the name again. $get = "SELECT `i` FROM `m` WHERE `i`=\"$r\""; $checkResults = mysql_query($getRandomness); while(mysql_num_row($checkResults) > 0) { //some code... //check again $get = "SELECT `i` FROM `m` WHERE `i`=$r"; $checkResults = mysql_query($get); } The error comes from the while line, but it comes up during the first check because the record is empty. This is the error: "Fatal error: Call to undefined function mysql_num_row()" This is suppose to check a table to see if it has a value in it. I get this error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /homepages/6/d365637117/htdocs/EE Live/Active/Inc/session.php on line 33 This is the code if($checkProfile) { $result = mysql_query("SELECT prof_pic FROM members_profile WHERE id = '".$_SESSION['EEID']."'"); $mem_num_rows = mysql_num_rows($result); if($mem_num_rows =1) { } What is the best way to check for a Date in a Form? I see there is a CheckDate() function, but how does that know what format the Date is in? Should I use a Regular Expression? My Form Field is just a Text Box... Thanks, Debbie Gud pm!! So i made this script to check if a username and password exist but it kinda fails me. It gives me a database connection error from my confirm_query() which means it returned false? so here's my code: Code: [Select] function check_if_exist($username, $password) { global $connection; $query = "SELECT username, hashed_password"; $query .= "FROM users "; $query .= "WHERE username = '$username' "; $query .= "AND hashed_password = '$password' "; $query .= " LIMIT 1"; $result_set = mysql_query($query, $connection); confirm_query($result_set); if(mysql_num_rows($result_set) == 1) { return true; } else { return false; } } my confirm_query(): Code: [Select] function confirm_query($result) { if(!$result) { die("Database connection failure ". mysql_error()); } } I have a another script to check if the email exist and it works perfectly, i dunno why this won't work properly.. maybe another simple mistake.. Any ideas or Violent reaction? Thanks! hey gys im trying to build a permissions system based on the users group. Groups can be 1, 2, or 3. Here is the code im using: <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("chat") or die(mysql_error()); $result = mysql_query("SELECT * FROM `members` WHERE username='".$_SESSION['username']."'") or die(mysql_error()); if($result["group"]==1){ echo 'yes'; } else { echo 'no'; } ?> And here is how my db looks like: The thing is, when Im logged in with the user test and run that script, its saying no as the group im in isnt 1. Why is this happening? Can someone help me fix my code. Hello.. I have Two HTML form and one is a Check boxes form that enable users to select their category. Then I need to display second form according to the categories they selected in first form. I use this code in first form to validate form submission.. if ( isset( $_POST['category']) && sizeof( $_POST['category']) <= 3) { $category = $_POST['category']; } else { $errors[] = 'Please select atleast 1, not more than 3 categories'; } If errors array is empty I did this.. if ( empty( $errors )) { // If everything's OK $_SESSION = $category; $url = 'http://localhost/lanka_institute/tutorsignup/select_subjects.php? // Define the URL. ob_end_clean(); // Delete the buffer. header("Location: $url"); exit(); // Quit the script. } Can I know and is this correct? I display category list from mysql category table, it has category name and category id this is my html part from first page echo '<td width="50%"><input type="checkbox" name="category[]" vlaue="' . $info['category_id'] . '" /> ' . $info['category_name'] . '</td>'; any help appreciated. Thanks in advance.. Hi, I am trying to see if the domain name in the string is in an array. eg; Code: [Select] mystring='http://google.com/somethingelse'; myarray[]='google.com'; myarray[]='anotherdomain.com'; in this case return TRUE Code: [Select] mystring='http://phpfreaks.com/adir'; myarray[]='google.com'; myarray[]='anotherdomain.com'; in this case return FALSE How would I do this? Thanks, -mme I have the variables $cap and $url If the $cap contains any of the strings ".jpg,.JPG,.gif,GIF" I have to concatenate $url.$cap Hi guys, I am trying to get a admin panel, which when the user is logged in, it will check if there user access is(say for this post) 9... If there access is 9 in the database then direct to admin panel if not return them home. Thanks guys I am new to PHP. I developed this class, I wonder if there's anything wrong or that I can improve. I could not test it because I'm in school. Thanks in advance. Code: [Select] <? class user { var $userID, $schoolID, $userName, $userPass, $dbHost, $dbUser, $dbName, $dbPass, $dbUserTable; $dbSchoolTable; function dbInfo() { $this->dbHost = 'localhost'; $this->dbUser = ''; $this->dbName = ''; $this->dbPass = ''; $this->dbUserTable = ''; $this->dbSchoolTable = ''; } function registerUser($userName, $userPass) { $dbLink = mysql_connect($this->dbHost, $this->dbUser, $this->dbPass); if(!$dbLink) die("Could not connect to database: " . mysql_error()); mysql_select_db($this->dbName); $query = "INSERT INTO $this->dbUserTable VALUES (NULL, \"$userName\", \"$userPass\")"; $result = mysql_query($query); if(!$result) { echo "Fail."; } else { $this->userID = mysql_insert_id(); } mysql_close($dbLink); $this->userName = $userName; $this->userPass = $userPass; } function registerSchool($schoolName) { $dbLink = mysql_connect($this->dbHost, $this->dbUser, $this->dbPass); if(!$dbLink) die("Could not connect to database: " . mysql_error()); mysql_select_db($this->dbName); $query = "INSERT INTO $this->dbSchoolTable VALUES (NULL, \"$schoolName\")"; $result = mysql_query($query); if(!$result) { echo "Fail."; } else { $this->schoolID = mysql_insert_id(); } mysql_close($dbLink); $this->schoolName = $schoolName; } function userLogin() { $dbLink = mysql_connect($this->dbHost, $this->dbUser, $this->dbPass); if(!$dbLink) die("Could not connect to database: " . mysql_error()); mysql_select_db($this->dbName); $query = "SELECT * FROM $this->dbUserTable WHERE userName = \"$this->userName\" AND userPass = \"$this->userPass\" LIMIT 1"; $result = mysql_query($query); if(!$result) { echo "Fail."; } else { while($row = mysql_fetch_array($result)) { session_start(); $_SESSION['userID'] = $row['userID']; session_write_close(); } } mysql_close($dbLink); } function changePass($newPass) { $dbLink = mysql_connect($this->dbHost, $this->dbUser, $this->dbPass); if(!$dbLink) die("Could not connect to database: " . mysql_error()); mysql_select_db($this->dbName); $query = "SELECT * FROM $this->dbUserTable WHERE userName = \"$this->userName\" LIMIT 1"; $result = mysql_query($query); if(!$result) { echo "Fail."; } else { $query = "UPDATE $this->dbUserTable SET userPass = \"$newPass\" WHERE userName = \"$this->userName\""; $result = mysql_query($query); if(!$result) { echo "Fail"; } else { $this->userPass = $newPass; } } mysql_close($dbLink); } } ?> does anyone have code for checking to make sure an email address is typed in correct Hi, I'd like to know what the most efficient code is for checking the first 2 digits of a string. eg a strings first 2 digits must equal '07' thanks, Code: [Select] public function getBonusChildren($userID) { if($userID != NULL) { $sql = 'SELECT COUNT(*) AS count, userID FROM jos_backoffice_users WHERE parentID= ' . $userID . ';'; $stmt = conn::getInstance()->prepare($sql); $stmt->execute(); $obj = $stmt->fetchAll(PDO::FETCH_ASSOC); if(is_object($obj)) { $obj->count += $this->getBonusChildren($obj->userID); } } return $obj->count; } I get no error. It just always return null. How can I get this done? Hi, I am trying to perform a login check and redirect the form to index.php if the username and password are correct. Also the login page check if the fields are entered or not. The issue is that the login check is performing but not redirecting to index.php. Also I'm not getting any error after performing the login check. Let me know if I'm making any errors in below code. the include file only contains the database details. Code: [Select] <?php include("connections.php"); ?> <?php if(isset($_POST['submit'])) { $errors=array(); $required_fields=array('username', 'pass'); foreach($required_fields as $fields) { if(!isset($_POST[$fields]) || empty($_POST[$fields])) { $errors[]=$fields; } } if(empty($errors)) { $username=trim($_POST['username']); $password =trim($_POST['pass']); $query= "SELECT * FROM users WHERE username='{$username}' AND hashed_password='{$password}' "; $result=mysql_query($query); $result_set=mysql_fetch_array($result); if(mysql_num_rows($result_set) == 1) { header('location: index.php'); exit; } else { echo 'Invalid password'; } } } ?> Hi , I have a login page that i acces via www.mydomain.com/logib.php?last_visited_page.php however the passed in variable last_visited_page.com is not always set . once the login script has run , when the variable it is not set i would want jump to myaccount.php otherwise jump to last_visited_page.php How do i check for no variable beinf present and therefore jump to myaccount.php Many Thanks Fraser |