Jump to content

ironman32

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ironman32's Achievements

Member

Member (2/5)

0

Reputation

  1. What is a simple way to debug a script? Please bear in mind that I do not have access to my php.ini file.
  2. I'm using this piece of code as part of an array but I just needed to know what it is or its purpose. srand((float) microtime() * 10000000); I've read about it at php.net but I still don't fully understand. Would someone be able to break it down please?
  3. Ok, but before I start is it possible to get the contents of a web page, turn it into a variable and then send it to the database?
  4. Ok I've created the table 'php_session' in my database. How will I go about getting the page content to the table?
  5. I already have a database set up. So whats' next? I'll have to set up a table for the data right? Would something like this be along the right lines? CREATE TABLE `php_session` ( `session_id` varchar(32) NOT NULL default '', `id` varchar(16) default NULL, `date_created` datetime NOT NULL default '0000-00-00 00:00:00', `last_updated` datetime NOT NULL default '0000-00-00 00:00:00', `session_data` longtext, PRIMARY KEY (`session_id`), KEY `last_updated` (`last_updated`) ) ENGINE=MyISAM I borrowed this from a tutorial on saving session data.
  6. Ok, I already have a login system setup with usernames and passwords. The exercises for the workout are displayed in tables. Here's an example of this code <table border="1"> Session 1 <tr><td>Stretch/Warm up</td></tr> <tr><td><?php echo $input[$rand_keys[0]] . "\n";?></td></tr> <tr><td><?php echo $input1[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input2[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input3[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input4[$rand_keys[0]] . "\n";?></td></tr> </table> Now if I wanted to send this table and its data to the database, how would I go about doing it? The only time I have sent data to the database was with a form but I don't know how to do it with a table.
  7. The idea is that I have a page on a site which shows the user a workout schedule. I want the user save the schedule shown on this page so that they can look at it later. The page will be custom for the user.
  8. I'm trying to save the state of a web page so that a user can access it and view it when they need to at a later date. Can anyone give me some guidance on this please?
  9. I have had a reoccurrence of an if statement problem. This if statement does not work if the user selects the value "yes". if($_POST['medical'] = "yes"){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); die(); } I'm not sure why this is because it looks ok to me. Can anyone shed some light on this?
  10. I'm trying to align these tables in this format Session 1 Session 2 Session 3 Session 4 Here is the code for the tables Session 1 <table border="1"> <tr><td>Stretch/Warm up</td></tr> <tr><td><?php echo $input[$rand_keys[0]] . "\n";?></td></tr> <tr><td><?php echo $input1[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input2[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input3[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input4[$rand_keys[0]] . "\n";?></td></tr> </table> <p> Session 2 <table border="1" > <tr><td>Stretch/Warm up</td></tr> <tr><td><?php echo $input[$rand_keys[0]] . "\n";?></td></tr> <tr><td><?php echo $input1[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input2[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input3[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input4[$rand_keys[0]] . "\n";?></td></tr> </table> </p> Session 3 <table border="1" > <tr><td>Stretch/Warm up</td></tr> <tr><td><?php echo $input9[$rand_keys[0]] . "\n";?></td></tr> <tr><td><?php echo $input10[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input11[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input12[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input13[$rand_keys[0]] . "\n";?></td></tr> <tr><td><?php echo $input14[$rand_keys[0]] . "\n";?></td></tr> </table> Session 4 <table border="1" > <tr><td>Stretch/Warm up</td></tr> <tr><td><?php echo $input15[$rand_keys[0]] . "\n";?></td></tr> <tr><td><?php echo $input16[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input17[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input18[$rand_keys[1]] . "\n";?></td></tr> </table> Could anyone give me some guidance on this please?
  11. Can anyone give me some advice on how to save data from a php page to the database. The aim is for the user to save the state of the page they are on to view at a later date. I've looked a this tutorial by Tony Marston, http://www.tonymarston.net/php-mysql/session-handler.html, but it was a bit confusing. I've only managed to define a table in the database so far. Any help would be appreciated.
  12. I've added 'die' after each header if ($_POST['age'] == '' ){ header("Location: lose.php?msg= Please enter your age and weight"); die(); } if ($_POST['weight'] == '' ){ header("Location: lose.php?msg= Please enter your weight and age"); die(); } if($_POST['weight'] > 19){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); die(); } if($_POST['age'] > 60){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); die(); } if($_POST['medical'] = 'yes'){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); die(); } else{ header("Location: lose_weight.php"); die(); } ?> But I can't seem to redirect the user to lose_weight.php. Even if age < 60 , weight < 19 and medical ='no' , I still get redirected to acute.php.
  13. I've changed the code to protect the data and I eliminated the parenthesis <?php $con = mysql_connect("localhost","dontwork","123qwerty123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db_name", $con); $age = mysql_real_escape_string($_POST['age']); $weight = mysql_real_escape_string($_POST['weight']); $medical = mysql_real_escape_string($_POST['medical']); if ($_POST['age'] == '' ){ header("Location: lose.php?msg= Please enter your age and weight"); } if ($_POST['weight'] == '' ){ header("Location: lose.php?msg= Please enter your weight and age"); } if($_POST['weight'] > 19){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); } if($_POST['age'] > 60){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); } if($_POST['medical'] == 'yes'){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); } else{ header("Location: lose_weight.php"); } ?> But only the last 'if' statement works. If the fields are blank the user still gets taken to lose_weight.php. I still need to get the other statements to work.
  14. Thanks but I still need to get these 'if' statements to work if(($_POST['weight']) > 19){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); } if(($_POST['age']) >60){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); }
×
×
  • 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.