-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
In order for the values of the selected checkboxes to be received in delete.php you need to have a form. Once you have the form implemented you can submit the form using the anchor tag if you wish. You'll set up the checkboxes with this echo ("<td ><input name=\"del[]\" value=\"{$row['ID']}\" type=\"checkbox\" /></td></tr>"); Now in delete.php how you'd proceses the selected checkboxes would be like this if(is_array($_GET['del'])) { $ids = array_map('intval', $_GET['del']); $ids = implode(',', $ids); $query = mysql_query("DELETE FROM your_table WHERE your_id_field IN ($ids)"); }
-
Your code as-s wont submit the checked values as <input />'s belong to forms not links. What you need to do is surround the table with a form that submits to delete.php. Then set the onsubmit attribute to the confirm dialog box which pops up when the submit button is pressed. <form action="delete.php" method="get" onsubmit="return confirm('Do you really want to DELETE ?');")> ... table code here ... <input type="submit" name="submit" value="Delete" /> </form>
-
This line $new_weight = $i-$pounds_lost Is causing the error. It should have a semi-colon (the ; character) at the end of the line. Also $i-$pounds_lost should be $i-$start_weight Your on the right path now.
-
Sorry my bad.
-
Do you know what for loop do? have you read http://php.net/for yet? Learn how the for loop works then try again. I have told you what you need to do to calculate the new weight and body fat. Loook at the lines that start with // in the code I posted.
-
Not quite, the loop needs to recalculate the weight and body fat on each iteration. for($i = 1; $i <= $pounds_lost; $i++) { //work out new body weight, take $i from $body_weight $new_weight = calculate new weight here; //recalculate body fat percentage, take $i from $start_body_fat and divide by new body weight and times by 100 $new_body_fat_percent = calculate new body fat percent here; // output how many pounds lost ($i), new weight and body fat percentage echo "After losing $i pounds of fat weight is now: $new_weight, body fat is: $new_body_fat_percent%"; } On each iteration of the loop you're giving new values to $new_weight and $new_body_fat_percent. The output from the loop will then look like
-
You can open the sendstats.conf file using file. This will load each line in the file to an array Now if you know that MailTo and MailFrom config is always going to be on a certain line, say lines 3 and 4 for example then you could do $config = file('sendstats.conf'); // read lines into array // change lines 3 and 4 to new config $config[2] = "MailTo = $new_MailTo\n"; // rewrite MailTo line $config[3] = "MailForm = $new_mailForm\n"; // rewrire MailForm line // rewrite config back to sendstats.conf file_put_contents('sendstats.conf', implode('', $config));
-
Some browsers limit what javascript can do when creating new windows. This for security purposes. These settings can only be override by the user. A better approach to popping up a (fake) window to display images is to use a light box. Example http://lokeshdhakar.com/projects/lightbox2/
-
You'll want to use a for loop. The code for the loop will be like for($i = 1; $i <= $pounds_lost; $i++) { // work out new body weight, take $i from $body_weight // recalculate body fat percentage, take $i from $start_body_fat and divide by new body weight and times by 100 // output how many pounds lost ($i), new weight and body fat percentage }
-
I dont think this a PHP problem to solve. You'll want to use javascript for this.
-
I have tested your code and it does work when the correct username/password is entered. You need to debug your code firther to see where it is failing. Also you are md5 hashing the posted password, make sure the passwords in the database are also hd5 hashed and not plain text. The query needs to compare the md5 hashes. I have modified your code so it spits out what it is doing as it processes the login. This is the sort of debug steps you need to take when code doesn't work the way you expect it to. <?php $dsn= 'mysql:host=localhost; dbname=softlearner'; $username= 'root'; $password= 'root'; try { $db= new PDO($dsn, $username, $password); echo '<p>You are connected to the database!</p>'; } catch (PDOException $e) { $error_message= $e->getMessage(); echo "<p>An error occured while connecting to the database: $error_message </p>"; } // only run code below if form has been posted if($_SERVER['REQUEST_METHOD'] == 'POST') { /* Debug */ printf('What is in $_POST <pre>%s</pre>', print_r($_POST, true)); if( isset($_POST['username'], $_POST['password']) && !empty($_POST['username']) && !empty($_POST['password']) ) { $username = $_POST['username']; $password = hash('md5',$_POST['password']); printf('Credentials: <pre>%s</pre>', print_r(array('username' => $username, 'password' => $password), true)); $sql= 'SELECT * FROM `members` WHERE `Username` = :username AND `Password` = :password LIMIT 1'; //SQL query with named placeholders $stmt = $db->prepare($sql); //Returns a PDOStatement class object $stmt->bindParam(':username',$username,PDO::PARAM_STR,16); $stmt->bindParam(':password',$password,PDO::PARAM_STR,16); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); } /* debug line */ $error = $stmt->errorInfo(); if($error[0] != '00000') printf('SQL Error: <pre>%s</pre>', print_r($error, true)); /* end debug line */ if($stmt->rowCount() > 0) { /*$_SESSION['loggedIn']= "true"; header("Location: index.php");*/ echo 'Login ok'; } else { echo 'Sorry username/password wrong'; } } else { echo 'No post data received'; } ?>
-
Sorry Change $name = isset($_POST['name']) ? $_POST['name'] : isset($_GET['name']) ? $_GET['name'] : ''; if(empty(trim($name))) echo 'Name required';to $name = (isset($_POST['name']) ? $_POST['name'] : (isset($_GET['name']) ? $_GET['name'] : '')); if(empty($name)) echo 'Name required';Should work ok now?
-
The script your using is wanting trying to write data to img/120300.png. So you need to give the file 120300.png sufficient write permissions. If it is creating the file 120300.png then you need to give the img/ folder sufficient write permissions. The following wiki article may help https://wiki.debian.org/Permissions
-
Yeah that was me. How is looking at your site unprofessional?
-
Did you see my post above why your code wasn't working correctly
-
Your if statement is wrong If ($count = 1) that argument will always return true and thus the class never changes. To compare if $count is equal to 1. You need to use the equals to comparison operator (==). The above line should read If ($count == 1)
-
I do not use mssql databases so I cant really help. It appears it is suggested to do the following $conn = mssql_connect( "SERVER", "username", "password" ); if(!$conn) die( "Err:conn - " . mssql_get_last_message()); $rs = mssql_select_db( "database", $conn); if(!rs) die( "ERR:Db- " . mssql_get_last_message()); as the api php uses for mssql returns status messages and these are what is triggering the or die, even though there isn't an error. So best to check if mssql_connect, mssql_select_db returned false.
-
How do you display the error message? The error message coming from form_process.php? What is popupbox? Basically what you need to do is check what is being sent back to create.php and then deciding what to do, whether to display modal, or the popupbox. But I dont know how you're implementing the popupbox so I cant tell you.
-
You can do something like $classes = array('class1', 'class2'); // define div classes here $i = -1; // initiate counter to -1 while(/* how you fetch next record */) { $class = $classes[++$i]; // get the next class, ++$i will increment $i by 1 echo '<div class="' . $class . '">your div contents</div>'; } On the first iteration it'll set the div class to class1 and on the secoud iteration it'll set the class to class2
-
By clear do you mean remove the actual form from the page, or clear the values entered into the form fields?
-
You can check how many arguments are being sent to a function using the func_num_args function. Example function myFunc($arg1, $arg2) { if(func_num_args() > 2) trigger_error('Can only pass two arguments to ' . __METHOD__ . ' method', E_USER_ERROR); // function code here } myFunc('one', 'two', 'three') // failes; myFunc('one', 'two') // passes;
-
Does adding $('#mailSetupForm')[0].reset(); after $('#wrapper').prepend(responseText); within the showResponse() function. Clear the form? Glad you have got it working now.