Jump to content

bschultz

Members
  • Posts

    486
  • Joined

  • Last visited

Everything posted by bschultz

  1. I can't seem to find any documentation on how to apply mktime to a variable. I have a url that will pass a date in the format of: xxxx-x-x I need to take that date, and find the previous month to that variable. Since I couldn't find any documentation on how to apply it to a variable, I tried this...which didn't work. $day = $_GET['day']; $previousmonth = "$day mktime(0, 0, 0, date('m')-1)"; How is this supposed to be done? Thanks.
  2. Good lord! That did it. Thank you both VERY MUCH!
  3. The radio buttons being labeled wrong might be the dumbest thing I've done all day! I put the semicolons back...and echoed $sqlquery...still nothing! <?php $md5_pass = md5($_POST[password]); $_SESSION["name"] = $_POST[name]; $_SESSION["address"] = $_POST[address]; $_SESSION["city"] = $_POST[city]; $_SESSION["state"] = $_POST[state]; $_SESSION["zip"] = $_POST[zip]; $_SESSION["age"] = $_POST[age]; $_SESSION["gender"] = $_POST[gender]; $_SESSION["email"] = $_POST[email]; $_SESSION["team"] = $_POST[team]; $_SESSION["team_name2"] = $_POST[team_name2]; $_SESSION["password"] = $md5_pass; echo "<img src='/shared/images/Go100forHealthLogo08_230.jpg' alt='go100' width='229' height='152' /> "; echo "<img src='/shared/images/all_stations.jpg' alt='all stations' width='339' height='156' /><br /><br />"; echo "You have entered the following information. Please check it over for accuracy.<br /><br />"; echo "Name: <strong>{$_SESSION['name']}</strong><br />"; echo "Address: <strong>{$_SESSION['address']}</strong><br />"; echo "City: <strong>{$_SESSION['city']}</strong><br />"; echo "State: <strong>{$_SESSION['state']}</strong><br />"; echo "Zip: <strong>{$_SESSION['zip']}</strong><br />"; echo "Age: <strong>{$_SESSION['age']}</strong><br />"; echo "Gender: <strong>{$_SESSION['gender']}</strong><br />"; echo "Email: <strong>{$_SESSION['email']}</strong><br />"; echo "Team Name: <strong>{$_SESSION['team']}</strong><br />"; echo "Manually Entered Team Name: <strong>{$_SESSION['team_name2']}</strong><br /><br />"; echo "<form id='form1' name='form1' method='post' action=''> <input type='hidden' name='name' id='name' value='{$_SESSION['name']}'/> <input type='hidden' name='address' id='address' value='{$_SESSION['address']}'/> <input type='hidden' name='city' id='city' value='{$_SESSION['city']}'/> <input type='hidden' name='state' id='state' value='{$_SESSION['state']}'/> <input type='hidden' name='zip' id='zip' value='{$_SESSION['zip']}'/> <input type='hidden' name='age' id='age' value='{$_SESSION['age']}'/> <input type='hidden' name='gender' id='gender' value='{$_SESSION['gender']}'/> <input type='hidden' name='email' id='email' value='{$_SESSION['email']}'/> <input type='hidden' name='password' id='password' value='{$_SESSION['password']}'/> <input type='hidden' name='team' id='team' value='{$_SESSION['team']}'/> <input type='hidden' name='team_name2' id='team_name2' value='{$_SESSION['team_name2']}'/> <strong>Is this information correct?</strong><br> <br> Yes <label> <input type='radio' name='confirmm' id='confirm' value='yes'> </label> No <label> <input type='radio' name='confirm' id='confirm' value='no'> </label><br /> <br /> <label> <input type='submit' name='button2' id='button2' value='Submit' /> </label> <br /> </form>"; $DBhost = "xxx"; $DBuser = "xxx"; $DBpass = "xxx"; $DBName = "xxx"; if ($_POST[confirm] == "yes") { $link = mysql_connect($DBhost,$DBuser,$DBpass); @mysql_select_db("$DBName") or die("Unable to select database $DBName"); if(!is_resource($link)) { echo "Failed to connect to the server\n"; } else { if(get_magic_quotes_gpc()) { $name = stripslashes($_POST['name']); $address = stripslashes($_POST['address']); $city = stripslashes($_POST['city']); $state = stripslashes($_POST['state']); $zip = stripslashes($_POST['zip']); $age = stripslashes($_POST['age']); $gender = stripslashes($_POST['gender']); $email = stripslashes($_POST['email']); $password = stripslashes($_POST['password']); $team = stripslashes($_POST['team']); $team_name2 = stripslashes($_POST['team)name2']); } else { $name = ($_POST['name']); $address = ($_POST['address']); $city = ($_POST['city']); $state = ($_POST['state']); $zip = ($_POST['zip']); $age = ($_POST['age']); $gender = ($_POST['gender']); $email = ($_POST['email']); $password = ($_POST['password']); $team = ($_POST['team']); $team_name2 = ($_POST['team)name2']); } $sqlquery = "INSERT INTO go100 VALUES('$_POST[name]', '$_POST[address]', '$_POST[city]', '$_POST[state]', '$_POST[zip]', '$_POST[age]', '$_POST[gender]', '$_POST[email]', '$_POST[password]', '$_POST[team]', '$_POST[team_name2]')"; echo $sqlquery; mysql_real_escape_string($name, $link); mysql_real_escape_string($address, $link); mysql_real_escape_string($city, $link); mysql_real_escape_string($state, $link); mysql_real_escape_string($zip, $link); mysql_real_escape_string($age, $link); mysql_real_escape_string($gender, $link); mysql_real_escape_string($email, $link); mysql_real_escape_string($password, $link); mysql_real_escape_string($team, $link); mysql_real_escape_string($team_name2, $link); $results = mysql_query($sqlquery, $link) or die(mysql_error()); echo "The information has been entered"; } } ?>
  4. No, I didn't get that echoed back to me. Upon looking more closely at the manual, I changed a semicolon to a comma after the insert (like the manual says), and changed semicolons to commas after the mysql_real_escape_string. Now I get an "Parse error: syntax error, unexpected ',' write_to_registration.php on line 113" Line 113 is this: mysql_real_escape_string($name, $link), <?php $sqlquery = "INSERT INTO go100 VALUES('$_POST[name]', '$_POST[address]', '$_POST[city]', '$_POST[state]', '$_POST[zip]', '$_POST[age]', '$_POST[gender]', '$_POST[email]', '$_POST[password]', '$_POST[team]', '$_POST[team_name2]')", mysql_real_escape_string($name, $link), mysql_real_escape_string($address, $link), mysql_real_escape_string($city, $link), mysql_real_escape_string($state, $link), mysql_real_escape_string($zip, $link), mysql_real_escape_string($age, $link), mysql_real_escape_string($gender, $link), mysql_real_escape_string($email, $link), mysql_real_escape_string($password, $link), mysql_real_escape_string($team, $link), mysql_real_escape_string($team_name2, $link), $_POST['name']);
  5. I REALLY appreciate the help! Still no insertion into the DB <?php $md5_pass = md5($_POST[password]); $_SESSION["name"] = $_POST[name]; $_SESSION["address"] = $_POST[address]; $_SESSION["city"] = $_POST[city]; $_SESSION["state"] = $_POST[state]; $_SESSION["zip"] = $_POST[zip]; $_SESSION["age"] = $_POST[age]; $_SESSION["gender"] = $_POST[gender]; $_SESSION["email"] = $_POST[email]; $_SESSION["team"] = $_POST[team]; $_SESSION["team_name2"] = $_POST[team_name2]; $_SESSION["password"] = $md5_pass; echo "<img src='/shared/images/Go100forHealthLogo08_230.jpg' alt='go100' width='229' height='152' /> "; echo "<img src='/shared/images/all_stations.jpg' alt='all stations' width='339' height='156' /><br /><br />"; echo "You have entered the following information. Please check it over for accuracy.<br /><br />"; echo "Name: <strong>{$_SESSION['name']}</strong><br />"; echo "Address: <strong>{$_SESSION['address']}</strong><br />"; echo "City: <strong>{$_SESSION['city']}</strong><br />"; echo "State: <strong>{$_SESSION['state']}</strong><br />"; echo "Zip: <strong>{$_SESSION['zip']}</strong><br />"; echo "Age: <strong>{$_SESSION['age']}</strong><br />"; echo "Gender: <strong>{$_SESSION['gender']}</strong><br />"; echo "Email: <strong>{$_SESSION['email']}</strong><br />"; echo "Team Name: <strong>{$_SESSION['team']}</strong><br />"; echo "Manually Entered Team Name: <strong>{$_SESSION['team_name2']}</strong><br /><br />"; echo "<form id='form1' name='form1' method='post' action=''> <input type='hidden' name='name' id='name' value='{$_SESSION['name']}'/> <input type='hidden' name='address' id='address' value='{$_SESSION['address']}'/> <input type='hidden' name='city' id='city' value='{$_SESSION['city']}'/> <input type='hidden' name='state' id='state' value='{$_SESSION['state']}'/> <input type='hidden' name='zip' id='zip' value='{$_SESSION['zip']}'/> <input type='hidden' name='age' id='age' value='{$_SESSION['age']}'/> <input type='hidden' name='gender' id='gender' value='{$_SESSION['gender']}'/> <input type='hidden' name='email' id='email' value='{$_SESSION['email']}'/> <input type='hidden' name='password' id='password' value='{$_SESSION['password']}'/> <input type='hidden' name='team' id='team' value='{$_SESSION['team']}'/> <input type='hidden' name='team_name2' id='team_name2' value='{$_SESSION['team_name2']}'/> <strong>Is this information correct?</strong><br> <br> Yes <label> <input type='radio' name='radio' id='confirm' value='yes'> </label> No <label> <input type='radio' name='radio' id='confirm' value='no'> </label><br /> <br /> <label> <input type='submit' name='button2' id='button2' value='Submit' /> </label> <br /> </form>"; $DBhost = "xxx"; $DBuser = "xxx"; $DBpass = "xxx"; $DBName = "xxx"; if ($_POST[confirm] == "yes") { $link = mysql_connect($DBhost,$DBuser,$DBpass); @mysql_select_db("$DBName") or die("Unable to select database $DBName"); if(!is_resource($link)) { echo "Failed to connect to the server\n"; } else { if(get_magic_quotes_gpc()) { $name = stripslashes($_POST['name']); $address = stripslashes($_POST['address']); $city = stripslashes($_POST['city']); $state = stripslashes($_POST['state']); $zip = stripslashes($_POST['zip']); $age = stripslashes($_POST['age']); $gender = stripslashes($_POST['gender']); $email = stripslashes($_POST['email']); $password = stripslashes($_POST['password']); $team = stripslashes($_POST['team']); $team_name2 = stripslashes($_POST['team)name2']); } else { $name = ($_POST['name']); $address = ($_POST['address']); $city = ($_POST['city']); $state = ($_POST['state']); $zip = ($_POST['zip']); $age = ($_POST['age']); $gender = ($_POST['gender']); $email = ($_POST['email']); $password = ($_POST['password']); $team = ($_POST['team']); $team_name2 = ($_POST['team)name2']); } $sqlquery = "INSERT INTO go100 VALUES('$_POST[name]', '$_POST[address]', '$_POST[city]', '$_POST[state]', '$_POST[zip]', '$_POST[age]', '$_POST[gender]', '$_POST[email]', '$_POST[password]', '$_POST[team]', '$_POST[team_name2]')"; mysql_real_escape_string($name, $link); mysql_real_escape_string($address, $link); mysql_real_escape_string($city, $link); mysql_real_escape_string($state, $link); mysql_real_escape_string($zip, $link); mysql_real_escape_string($age, $link); mysql_real_escape_string($gender, $link); mysql_real_escape_string($email, $link); mysql_real_escape_string($password, $link); mysql_real_escape_string($team, $link); mysql_real_escape_string($team_name2, $link); $results = mysql_query($sqlquery) or die(mysql_error()); echo "The information has been entered"; } } ?> {/code]
  6. Still no error and still not inserting <?php $md5_pass = md5($_POST[password]); $_SESSION["name"] = $_POST[name]; $_SESSION["address"] = $_POST[address]; $_SESSION["city"] = $_POST[city]; $_SESSION["state"] = $_POST[state]; $_SESSION["zip"] = $_POST[zip]; $_SESSION["age"] = $_POST[age]; $_SESSION["gender"] = $_POST[gender]; $_SESSION["email"] = $_POST[email]; $_SESSION["team"] = $_POST[team]; $_SESSION["team_name2"] = $_POST[team_name2]; $_SESSION["password"] = $md5_pass; echo "<img src='/shared/images/Go100forHealthLogo08_230.jpg' alt='go100' width='229' height='152' /> "; echo "<img src='/shared/images/all_stations.jpg' alt='all stations' width='339' height='156' /><br /><br />"; echo "You have entered the following information. Please check it over for accuracy.<br /><br />"; echo "Name: <strong>{$_SESSION['name']}</strong><br />"; echo "Address: <strong>{$_SESSION['address']}</strong><br />"; echo "City: <strong>{$_SESSION['city']}</strong><br />"; echo "State: <strong>{$_SESSION['state']}</strong><br />"; echo "Zip: <strong>{$_SESSION['zip']}</strong><br />"; echo "Age: <strong>{$_SESSION['age']}</strong><br />"; echo "Gender: <strong>{$_SESSION['gender']}</strong><br />"; echo "Email: <strong>{$_SESSION['email']}</strong><br />"; echo "Team Name: <strong>{$_SESSION['team']}</strong><br />"; echo "Manually Entered Team Name: <strong>{$_SESSION['team_name2']}</strong><br /><br />"; echo "<form id='form1' name='form1' method='post' action=''> <input type='hidden' name='name' id='name' value='{$_SESSION['name']}'/> <input type='hidden' name='address' id='address' value='{$_SESSION['address']}'/> <input type='hidden' name='city' id='city' value='{$_SESSION['city']}'/> <input type='hidden' name='state' id='state' value='{$_SESSION['state']}'/> <input type='hidden' name='zip' id='zip' value='{$_SESSION['zip']}'/> <input type='hidden' name='age' id='age' value='{$_SESSION['age']}'/> <input type='hidden' name='gender' id='gender' value='{$_SESSION['gender']}'/> <input type='hidden' name='email' id='email' value='{$_SESSION['email']}'/> <input type='hidden' name='password' id='password' value='{$_SESSION['password']}'/> <input type='hidden' name='team' id='team' value='{$_SESSION['team']}'/> <input type='hidden' name='team_name2' id='team_name2' value='{$_SESSION['team_name2']}'/> <strong>Is this information correct?</strong><br> <br> Yes <label> <input type='radio' name='radio' id='confirm' value='yes'> </label> No <label> <input type='radio' name='radio' id='confirm' value='no'> </label><br /> <br /> <label> <input type='submit' name='button2' id='button2' value='Submit' /> </label> <br /> </form>"; if ($_POST[confirm] == "yes") { $DBhost = "xxx"; $DBuser = "xxx"; $DBpass = "xxx"; $DBName = "xxx"; if (isset($_POST['confirm'])) { $link = mysql_connect($DBhost,$DBuser,$DBpass); @mysql_select_db("$DBName") or die("Unable to select database $DBName"); if(!is_resource($link)) { echo "Failed to connect to the server\n"; } else { $sqlquery = "INSERT INTO go100 VALUES('$_POST[name]', '$_POST[address]', '$_POST[city]', '$_POST[state]', '$_POST[zip]', '$_POST[age]', '$_POST[gender]', '$_POST[email]', '$_POST[password]', '$_POST[team]', '$_POST[team_name2]')"; mysql_real_escape_string($_POST["name"], $link); mysql_real_escape_string($_POST["name"], $link); mysql_real_escape_string($_POST["address"], $link); mysql_real_escape_string($_POST["city"], $link); mysql_real_escape_string($_POST["state"], $link); mysql_real_escape_string($_POST["zip"], $link); mysql_real_escape_string($_POST["age"], $link); mysql_real_escape_string($_POST["gender"], $link); mysql_real_escape_string($_POST["email"], $link); mysql_real_escape_string($_POST["password"], $link); mysql_real_escape_string($_POST["team"], $link); mysql_real_escape_string($_POST["team_name2"], $link); $results = mysql_query($sqlquery) or die(mysql_error()); echo "The information has been entered"; } } } ?>
  7. No insertion...and no error. <?php $md5_pass = md5($_POST[password]); $_SESSION["name"] = $_POST[name]; $_SESSION["address"] = $_POST[address]; $_SESSION["city"] = $_POST[city]; $_SESSION["state"] = $_POST[state]; $_SESSION["zip"] = $_POST[zip]; $_SESSION["age"] = $_POST[age]; $_SESSION["gender"] = $_POST[gender]; $_SESSION["email"] = $_POST[email]; $_SESSION["team"] = $_POST[team]; $_SESSION["team_name2"] = $_POST[team_name2]; $_SESSION["password"] = $md5_pass; echo "<img src='/shared/images/Go100forHealthLogo08_230.jpg' alt='go100' width='229' height='152' /> "; echo "<img src='/shared/images/all_stations.jpg' alt='all stations' width='339' height='156' /><br /><br />"; echo "You have entered the following information. Please check it over for accuracy.<br /><br />"; echo "Name: <strong>{$_SESSION['name']}</strong><br />"; echo "Address: <strong>{$_SESSION['address']}</strong><br />"; echo "City: <strong>{$_SESSION['city']}</strong><br />"; echo "State: <strong>{$_SESSION['state']}</strong><br />"; echo "Zip: <strong>{$_SESSION['zip']}</strong><br />"; echo "Age: <strong>{$_SESSION['age']}</strong><br />"; echo "Gender: <strong>{$_SESSION['gender']}</strong><br />"; echo "Email: <strong>{$_SESSION['email']}</strong><br />"; echo "Team Name: <strong>{$_SESSION['team']}</strong><br />"; echo "Manually Entered Team Name: <strong>{$_SESSION['team_name2']}</strong><br /><br />"; echo "<form id='form1' name='form1' method='post' action=''> <input type='hidden' name='name' id='name' value='{$_SESSION['name']}'/> <input type='hidden' name='address' id='address' value='{$_SESSION['address']}'/> <input type='hidden' name='city' id='city' value='{$_SESSION['city']}'/> <input type='hidden' name='state' id='state' value='{$_SESSION['state']}'/> <input type='hidden' name='zip' id='zip' value='{$_SESSION['zip']}'/> <input type='hidden' name='age' id='age' value='{$_SESSION['age']}'/> <input type='hidden' name='gender' id='gender' value='{$_SESSION['gender']}'/> <input type='hidden' name='email' id='email' value='{$_SESSION['email']}'/> <input type='hidden' name='password' id='password' value='{$_SESSION['password']}'/> <input type='hidden' name='team' id='team' value='{$_SESSION['team']}'/> <input type='hidden' name='team_name2' id='team_name2' value='{$_SESSION['team_name2']}'/> <strong>Is this information correct?</strong><br> <br> Yes <label> <input type='radio' name='radio' id='confirm' value='yes'> </label> No <label> <input type='radio' name='radio' id='confirm' value='no'> </label><br /> <br /> <label> <input type='submit' name='button2' id='button2' value='Submit' /> </label> <br /> </form>"; echo $sqlquery; if ($_POST[confirm] == "yes") { $DBhost = "xxx"; $DBuser = "xxx"; $DBpass = "xxx"; $DBName = "xxx"; mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database"); @mysql_select_db("$DBName") or die("Unable to select database $DBName"); $sqlquery = "INSERT INTO go100 VALUES('{$_SESSION[name]}', '{$_SESSION[address]}', '{$_SESSION[city]}', '{$_SESSION[state]}', '{$_SESSION[zip]}', '{$_SESSION[age]}', '{$_SESSION[gender]}', '{$_SESSION[email]}', '{$_SESSION[password]}', '{$_SESSION[team]}', '{$_SESSION[team_name2]}')"; mysql_real_escape_string($_SESSION["name"], $_SESSION["address"], $_SESSION["city"], $_SESSION["state"], $_SESSION["zip"], $_SESSION["age"], $_SESSION["gender"], $_SESSION["email"], $_SESSION["password"], $_SESSION["team"], $_SESSION["team_name2"]); $results = mysql_query($sqlquery) or die(mysql_error()); echo "The information has been entered"; } else echo $sqlquery; ?>
  8. Still no insertion into the DB <?php $md5_pass = md5($_POST[password]); $_SESSION["name"] = $_POST[name]; $_SESSION["address"] = $_POST[address]; $_SESSION["city"] = $_POST[city]; $_SESSION["state"] = $_POST[state]; $_SESSION["zip"] = $_POST[zip]; $_SESSION["age"] = $_POST[age]; $_SESSION["gender"] = $_POST[gender]; $_SESSION["email"] = $_POST[email]; $_SESSION["team"] = $_POST[team]; $_SESSION["team_name2"] = $_POST[team_name2]; $_SESSION["password"] = $md5_pass; echo "<img src='/shared/images/Go100forHealthLogo08_230.jpg' alt='go100' width='229' height='152' /> "; echo "<img src='/shared/images/all_stations.jpg' alt='all stations' width='339' height='156' /><br /><br />"; echo "You have entered the following information. Please check it over for accuracy.<br /><br />"; echo "Name: <strong>{$_SESSION['name']}</strong><br />"; echo "Address: <strong>{$_SESSION['address']}</strong><br />"; echo "City: <strong>{$_SESSION['city']}</strong><br />"; echo "State: <strong>{$_SESSION['state']}</strong><br />"; echo "Zip: <strong>{$_SESSION['zip']}</strong><br />"; echo "Age: <strong>{$_SESSION['age']}</strong><br />"; echo "Gender: <strong>{$_SESSION['gender']}</strong><br />"; echo "Email: <strong>{$_SESSION['email']}</strong><br />"; echo "Team Name: <strong>{$_SESSION['team']}</strong><br />"; echo "Manually Entered Team Name: <strong>{$_SESSION['team_name2']}</strong><br /><br />"; echo "<form id='form1' name='form1' method='post' action=''> <input type='hidden' name='name' id='name' value='{$_SESSION['name']}'/> <input type='hidden' name='address' id='address' value='{$_SESSION['address']}'/> <input type='hidden' name='city' id='city' value='{$_SESSION['city']}'/> <input type='hidden' name='state' id='state' value='{$_SESSION['state']}'/> <input type='hidden' name='zip' id='zip' value='{$_SESSION['zip']}'/> <input type='hidden' name='age' id='age' value='{$_SESSION['age']}'/> <input type='hidden' name='gender' id='gender' value='{$_SESSION['gender']}'/> <input type='hidden' name='email' id='email' value='{$_SESSION['email']}'/> <input type='hidden' name='password' id='password' value='{$_SESSION['password']}'/> <input type='hidden' name='team' id='team' value='{$_SESSION['team']}'/> <input type='hidden' name='team_name2' id='team_name2' value='{$_SESSION['team_name2']}'/> <strong>Is this information correct?</strong><br> <br> Yes <label> <input type='radio' name='radio' id='confirm' value='yes'> </label> No <label> <input type='radio' name='radio' id='confirm' value='no'> </label><br /> <br /> <label> <input type='submit' name='button2' id='button2' value='Submit' /> </label> <br /> </form>"; if ($_POST[confirm] == "yes") { $DBhost = "xxx"; $DBuser = "xxx"; $DBpass = "xxx"; $DBName = "xxx"; mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database"); @mysql_select_db("$DBName") or die("Unable to select database $DBName"); $sqlquery = "INSERT INTO go100 VALUES ('{$_SESSION[name]}', '{$_SESSION[address]}', '{$_SESSION[city]}', '{$_SESSION[state]}', '{$_SESSION[zip]}', '{$_SESSION[age]}', '{$_SESSION[gender]}', '{$_SESSION[email]}', '{$_SESSION[password]}', '{$_SESSION[team]}', '{$_SESSION[team_name2]}')"; $results = mysql_query($sqlquery); echo "The information has been entered"; } else echo $sqlquery; ?> I'll mess with mysql_real_escape_string once I get it to insert.
  9. I'm all for easier ways (and learning better ways). What would you do?
  10. Since the insert query used the session variables, I thought that I wouldn't need them in the second form. Learn something new everyday, right?
  11. I am only running the query after the second submit button is clicked. Just to make sure it wasn't running it twice, I moved the db connection to after the if statement. Here's the new code, which doesn't echo anything in the "echo $sqlquery;" line...so it isn't running the db query at all. <?php $md5_pass = md5($_POST[password]); $_SESSION["name"] = $_POST[name]; $_SESSION["address"] = $_POST[address]; $_SESSION["city"] = $_POST[city]; $_SESSION["state"] = $_POST[state]; $_SESSION["zip"] = $_POST[zip]; $_SESSION["age"] = $_POST[age]; $_SESSION["gender"] = $_POST[gender]; $_SESSION["email"] = $_POST[email]; $_SESSION["team"] = $_POST[team]; $_SESSION["team_name2"] = $_POST[team_name2]; $_SESSION["password"] = $md5_pass; echo "<img src='/shared/images/Go100forHealthLogo08_230.jpg' alt='go100' width='229' height='152' /> "; echo "<img src='/shared/images/all_stations.jpg' alt='all stations' width='339' height='156' /><br /><br />"; echo "You have entered the following information. Please check it over for accuracy.<br /><br />"; echo "Name: <strong>{$_SESSION['name']}</strong><br />"; echo "Address: <strong>{$_SESSION['address']}</strong><br />"; echo "City: <strong>{$_SESSION['city']}</strong><br />"; echo "State: <strong>{$_SESSION['state']}</strong><br />"; echo "Zip: <strong>{$_SESSION['zip']}</strong><br />"; echo "Age: <strong>{$_SESSION['age']}</strong><br />"; echo "Gender: <strong>{$_SESSION['gender']}</strong><br />"; echo "Email: <strong>{$_SESSION['email']}</strong><br />"; echo "Team Name: <strong>{$_SESSION['team']}</strong><br />"; echo "Manually Entered Team Name: <strong>{$_SESSION['team_name2']}</strong><br /><br />"; echo "<form id='form1' name='form1' method='post' action=''> <input type='hidden' name='name' id='name' value='{$_SESSION['name']}'/> <input type='hidden' name='address' id='address' value='{$_SESSION['address']}'/> <input type='hidden' name='city' id='city' value='{$_SESSION['city']}'/> <input type='hidden' name='state' id='state' value='{$_SESSION['state']}'/> <input type='hidden' name='zip' id='zip' value='{$_SESSION['zip']}'/> <input type='hidden' name='age' id='age' value='{$_SESSION['age']}'/> <input type='hidden' name='gender' id='gender' value='{$_SESSION['gender']}'/> <input type='hidden' name='email' id='email' value='{$_SESSION['email']}'/> <input type='hidden' name='password' id='password' value='{$_SESSION['password']}'/> <input type='hidden' name='team' id='name' team='{$_SESSION['team']}'/> <input type='hidden' name='team_name2' id='team_name2' value='{$_SESSION['team_name2']}'/> <strong>Is this information correct?</strong><br> <br> Yes <label> <input type='radio' name='radio' id='confirm' value='yes'> </label> No <label> <input type='radio' name='radio' id='confirm' value='no'> </label><br /> <br /> <label> <input type='submit' name='button2' id='button2' value='Submit' /> </label> <br /> </form>"; if ($_POST[confirm] == "yes") { $DBhost = "xxx"; $DBuser = "xxx"; $DBpass = "xxx"; $DBName = "xxx"; mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database"); @mysql_select_db("$DBName") or die("Unable to select database $DBName"); $sqlquery = "INSERT INTO go100 VALUES('$_SESSION[name]', '$_SESSION[address]', '$_SESSION[city]', '$_SESSION[state]', '$_SESSION[zip]', '$_SESSION[age]', '$_SESSION[gender]', '$_SESSION[email]', '$md5_pass', '$_SESSION[team]', '$_SESSION[team_name2]')"; $results = mysql_query($sqlquery); echo "The information has been entered"; } else echo $sqlquery; // mysql_close (); ?>
  12. Thanks for the help gevans... I changed the code, but it still doesn't insert anything into the database, and the second echo of $sqlquery shows this: while the first one shows this (as it should):
  13. I've got a php script that will take form fields, and write them to a database. Pretty simple, and working just fine. I, however, want the user typing in the form to be displayed the answers that they have typed...and be able to confirm that they typed everything properly. This is not working. Here's the code: <?php $md5_pass = md5($_POST[password]); $_SESSION["name"] = $_POST[name]; $_SESSION["address"] = $_POST[address]; $_SESSION["city"] = $_POST[city]; $_SESSION["state"] = $_POST[state]; $_SESSION["zip"] = $_POST[zip]; $_SESSION["age"] = $_POST[age]; $_SESSION["gender"] = $_POST[gender]; $_SESSION["email"] = $_POST[email]; $_SESSION["team"] = $_POST[team]; $_SESSION["team_name2"] = $_POST[team_name2]; $_SESSION["password"] = $md5_pass; mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database"); @mysql_select_db("$DBName") or die("Unable to select database $DBName"); $sqlquery = "INSERT INTO go100 VALUES('$_SESSION[name]', '$_SESSION[address]', '$_SESSION[city]', '$_SESSION[state]', '$_SESSION[zip]', '$_SESSION[age]', '$_SESSION[gender]', '$_SESSION[email]', '$_SESSION[password]', '$_SESSION[team]', '$_SESSION[team_name2]')"; echo "You have entered the following information. Please check it over for accuracy.<br /><br />"; echo "Name: <strong>$_SESSION[name]</strong><br />"; echo "Address: <strong>$_SESSION[address]</strong><br />"; echo "City: <strong>$_SESSION[city]</strong><br />"; echo "State: <strong>$_SESSION[state]</strong><br />"; echo "Zip: <strong>$_SESSION[zip]</strong><br />"; echo "Age: <strong>$_SESSION[age]</strong><br />"; echo "Gender: <strong>$_SESSION[gender]</strong><br />"; echo "Email: <strong>$_SESSION[email]</strong><br />"; echo "Team Name: <strong>$_SESSION[team]</strong><br />"; echo "Manually Entered Team Name: <strong>$_SESSION[team_name2]</strong><br /><br />"; echo "<form id='form1' name='form1' method='post' action=''> <strong>Is this information correct?</strong><br> <br> Yes <label> <input type='radio' name='radio' id='confirm' value='yes'> </label> No <label> <input type='radio' name='radio' id='confirm' value='no'> </label><br /> <br /> <label> <input type='submit' name='button2' id='button2' value='Submit' /> </label> <br /> </form>"; if ($_POST[confirm] == "yes") { $results = mysql_query($sqlquery); echo "The information has been entered"; } else echo $sqlquery; mysql_close (); ?> The echo of echo $sqlquery; in the last few lines of the code displays the correct info, but once the second submit button is checked, the data is lost (echo $sqlquery shows blank info) and the database isn't even populated with blank info. Any idea what I'm doing wrong?
  14. God, I hate quotes and brackets! That did it. Thanks.
  15. To help in troubleshooting, I've added a field in the database. I now have a field for dayofweek, and a field for dayofmonth (these are for the recurring events). Unfortunately, the code still fails: $sql = "SELECT * FROM dayplanner WHERE $newday BETWEEN startdate AND enddate AND (dayofmonth = 'DAYOFMONTH('$newday')' OR dayofweek = 'DAYOFWEEK('$newday')')";
  16. Thanks for the help...the first part of the query works. The only part that doesn't is the "recurring" part. Here's the new code: $sql = "SELECT * FROM dayplanner WHERE $newday BETWEEN startdate AND enddate AND (recurring = 'DAYOFMONTH('$newday')' OR recurring = 'DAYOFWEEK('$newday')')"; $rs = mysql_query($sql,$dbc); $matches = 0; while ($row = mysql_fetch_assoc($rs)) { $matches++; echo "$row[event]<br />"; } if (! $matches) { echo "no matches here"; } It throws an error on this line... while ($row = mysql_fetch_assoc($rs)) { ...so it's not pulling the correct date or day from the db. Could this have something to do with the fact that using BETWEEN removes the dashes from the date field? So instead of 2009-05-07, it's 20090507.
  17. I'm trying to select records from the database that fall between the start date and the end date AND also (if they are recurring events) fall on the correct day of the week or the date of the month. Here's what I have: $newday = $_GET['day']; $sql = "SELECT * FROM dayplanner WHERE $newday BETWEEN startdate AND enddate AND '$newday = 'date('l')' OR '$newday = 'date('d')''"; The format of $_GET['day'] is the mysql date format (2009-05-07). Obviously, my code won't work, because I haven't figured out what day of the week, or date of the month, the url is passing. How can I determine from 2009-05-07 what day of the week and date of the month it is? Thanks.
  18. Ok...moral of the story here is when copying and pasting, change ALL of the variable and form field names...not just some of them! script worked fine as soon as i changed the form fields name! Thanks for the help, though, guys!
  19. "<?php echo $row[row_number]; ?>" still deletes everything in "gender" and "visitor" for every record
  20. I have a script that works on one server, but doesn't on another server. The server that doesn't work does have a few more variables and columns in the DB, but the code is in essence, the same. Here's the code to display the DB contents into an html table: <?php //do your normal mysql setup and connection calls $dbc = mysql_connect(xxx,xxx,xxx); mysql_select_db('refs',$dbc); //now get stuff from a table $sql = "SELECT * FROM calendar1"; $dbq = mysql_query($sql,$dbc); //now spit out the table and rows for the table $rs = mysql_query($sql,$dbc); $matches = 0; ?><table width='100%' border='1'> <form method="POST" action="edit_db.php"> <p style="margin-bottom: 0"><br> <font color="#000000"> </font></p> <tr> <td><div align="center">Delete</div></td> <td><div align="center">Row Number</div></td> <td><div align="center">Date</div></td> <td><div align="center">Gender</div></td> <td><div align="center">Visitor</div></td> <td><div align="center">Home</div></td> <td><div align="center">Time</div></td> <td><div align="center">Ref 1</div></td> <td><div align="center">Ref 2</div></td> <td><div align="center">Ref 3</div></td> <td><div align="center">Ref 4</div></td> </tr> <tr> <?php $i = 0; while ($row = mysql_fetch_assoc($rs)) { $matches++; ?> <td><div align="center"><font color="#000000"> <input name="cmd[<?php echo $i; ?>]" type="checkbox" id="cmd" value="delete" /> </font></div></td> <td> <input name="row_number[<?php echo $i; ?>]" type="text" id="row_number" value="<?php echo"$row[row_number]" ?>" /> </td> <td><div align="center"><font color="#000000"> <input name="date[<?php echo $i; ?>]" type="text" id="date" size="10" maxlength="10" value="<?php echo"$row[date]" ?>" /> </font></div></td> <td><div align="center"> <input name="type[<?php echo $i; ?>]" type="text" id="type" size="10" maxlength="15" value="<?php echo"$row[gender]" ?>" /> </div></td> <td><div align="center"> <input name="event[<?php echo $i; ?>]" type="text" id="event" size="30" maxlength="30" value="<?php echo"$row[visitor]" ?>" /> </div></td> <td><div align="center"><font color="#000000"> <input name="home[<?php echo $i; ?>]" type="text" id="action" size="30" maxlength="30" value="<?php echo"$row[home]" ?>" /> </font></div></td> <td><div align="center"><font color="#000000"> <input name="time[<?php echo $i; ?>]" type="text" id="action" size="30" maxlength="30" value="<?php echo"$row[time]" ?>" /> </font></div></td> <td><div align="center"><font color="#000000"> <input name="ref1[<?php echo $i; ?>]" type="text" id="comments" size="30" maxlength="30" value="<?php echo"$row[ref1]" ?>" /> </font></div></td> <td><div align="center"><font color="#000000"> <input name="ref2[<?php echo $i; ?>]" type="text" id="comments" size="30" maxlength="30" value="<?php echo"$row[ref2]" ?>" /> </font></div></td> <td><div align="center"><font color="#000000"> <input name="ref3[<?php echo $i; ?>]" type="text" id="comments" size="30" maxlength="30" value="<?php echo"$row[ref3]" ?>" /> </font></div></td> <td><div align="center"><font color="#000000"> <input name="ref4[<?php echo $i; ?>]" type="text" id="comments" size="30" maxlength="30" value="<?php echo"$row[ref4]" ?>" /> </font></div></td> </tr> <?php $i++; } if (! $matches) { echo ("</table>There are no matches today"); } echo "</TABLE>"; ?> <input name="submit" type="submit" value="Submit" /> <input type="reset" name="Reset" value="Reset" /> </form> And here's the edit_db.php code: <?php $DBName = "refs"; $connect = mysql_connect("$host", "$username", "$password"); $conn1 = $connect; @mysql_select_db("$DBName") or die("Unable to select database $DBName"); $date = $_POST[date]; $gender = $_POST[gender]; $visitor = $_POST[visitor]; $home = $_POST[home]; $time = $_POST[time]; $ref1 = $_POST[ref1]; $ref2 = $_POST[ref2]; $ref3 = $_POST[ref3]; $ref4 = $_POST[ref4]; $row_number = $_POST[row_number]; $cmd = $_POST[cmd]; for ($i=0;$i<count($_POST[date]);$i++){ if($cmd[$i] =="delete") { $sqldelete = "DELETE FROM calendar1 WHERE row_number='$row_number[$i]'"; $resultdelete = mysql_query($sqldelete) or die ("Error in Delete Query" . mysql_error()); } else $usql = "UPDATE calendar1 SET date='$date[$i]', gender='$gender[$i]', visitor='$visitor[$i]', home='$home[$i]', time='$time[$i]', ref1='$ref1[$i]', ref2='$ref2[$i]', ref3='$ref3[$i]', ref4='$ref4[$i]' WHERE row_number='$row_number[$i]'"; // above compiles query $dosql = mysql_query($usql); // executes query } if ($dosql){ //echo $dosql; echo $sqldelete; echo "<p>Thank You, your entry has been submitted!</p> <meta http-equiv=Refresh content=5;url='edit.php'>"; } else{ echo mysql_errno().": ".mysql_error()."<BR>"; } mysql_close (); ?> The code above doesn't update anything, and in fact, deletes every "gender" and "visitor" in the DB (all 115 records!). Like I said, pretty much the same code works on one server (only has five variables and columns in the Db, as opposed to ten on the server that doesn't work), just doesn't work on the second server. Any ideas what might be wrong? Thanks. Brian
  21. I decided that changing the code to use a GET variable would be much easier than printing out the calendar for six months at a time. Thanks for the help, though!... For those that want the code: <?php // get this month and this years as an int $thismonth = $_GET["thismonth"]; $thisyear = $_GET["thisyear"]; // find out the number of days in the month $numdaysinmonth = cal_days_in_month( CAL_GREGORIAN, $thismonth, $thisyear ); // create a calendar object $jd = cal_to_jd( CAL_GREGORIAN, $thismonth, date( 1 ), $thisyear ); // get the start day as an int (0 = Sunday, 1 = Monday, etc) $startday = jddayofweek( $jd , 0 ); // get the month as a name $monthname = jdmonthname( $jd, 1 ) ?> <table> <tr> <td colspan="7"><div align="center"><strong> <?php if($_GET[thismonth]=='01') echo('January'); else if($_GET[thismonth]=='02') echo('February'); else if($_GET[thismonth]=='03') echo('March'); else if($_GET[thismonth]=='04') echo('April'); else if($_GET[thismonth]=='05') echo('May'); else if($_GET[thismonth]=='06') echo('June'); else if($_GET[thismonth]=='07') echo('July'); else if($_GET[thismonth]=='08') echo('August'); else if($_GET[thismonth]=='09') echo('September'); else if($_GET[thismonth]=='10') echo('October'); else if($_GET[thismonth]=='11') echo('November'); else if($_GET[thismonth]=='12') echo('December'); else echo ""; echo " $thisyear"; ?></strong></div></td> </tr> <tr> <td><strong>Sunday</strong></td> <td><strong>Monday</strong></td> <td><strong>Tuesday</strong></td> <td><strong>Wednesday</strong></td> <td><strong>Thursday</strong></td> <td><strong>Friday</strong></td> <td><strong>Saturday</strong></td> </tr> <tr> <?php // put render empty cells $emptycells = 0; for( $counter = 0; $counter < $startday; $counter ++ ) { echo "\t\t<td>-</td>\n"; $emptycells ++; } // renders the days $rowcounter = $emptycells; $numinrow = 7; for( $counter = 1; $counter <= $numdaysinmonth; $counter ++ ) { $rowcounter ++; echo "\t\t<td valign='top'>$counter<br />"; //do your normal mysql setup and connection calls $dbc = mysql_pconnect('xxx','xxx','xxx'); mysql_select_db('refs',$dbc); //now get stuff from a table $sql = "SELECT * FROM calendar WHERE date='$thisyear-$thismonth-$counter'"; $rs = mysql_query($sql,$dbc); $matches = 0; while ($row = mysql_fetch_assoc($rs)) { $matches++; echo "---------------------<br />"; echo "$row[time]"." <br /><strong>$row[gender]"." $row[visitor]"." at "."$row[home]</strong><br />"; echo "$row[ref1] "."$row[ref2] "."$row[ref3] "."$row[ref4]<br />"; } if (! $matches) { echo "---------------------"; } echo ""; echo "</td>\n"; if( $rowcounter % $numinrow == 0 ) { echo "\t</tr>\n"; if( $counter < $numdaysinmonth ) { echo "\t<tr>\n"; } $rowcounter = 0; } } // clean up $numcellsleft = $numinrow - $rowcounter; if( $numcellsleft != $numinrow ) { for( $counter = 0; $counter < $numcellsleft; $counter ++ ) { echo "\t\t<td>-</td>\n"; $emptycells ++; } } ?> </tr> </table> </body> </html>
  22. I have a calendar that draws info from a MYSQL database and spits it out into a table. It's a combination of several php calendars that I've found. I do, however, need some help altering it to do more than one moth at a time. I'd like it to show the next 6 months. Here's the code: <?php $m = date(m); $d = date(d); $y = date(Y); // get this month and this years as an int $thismonth = ( int ) date( "m" ); $thisyear = date( "Y" ); // find out the number of days in the month $numdaysinmonth = cal_days_in_month( CAL_GREGORIAN, $thismonth, $thisyear ); // create a calendar object $jd = cal_to_jd( CAL_GREGORIAN, date( "m" ),date( 1 ), date( "Y" ) ); // get the start day as an int (0 = Sunday, 1 = Monday, etc) $startday = jddayofweek( $jd , 0 ); // get the month as a name $monthname = jdmonthname( $jd, 1 ) ?> <table> <tr> <td colspan="7"><div align="center"><strong><?php echo "$monthname $thisyear"; ?></strong></div></td> </tr> <tr> <td><strong>Sunday</strong></td> <td><strong>Monday</strong></td> <td><strong>Tuesday</strong></td> <td><strong>Wednesday</strong></td> <td><strong>Thursday</strong></td> <td><strong>Friday</strong></td> <td><strong>Saturday</strong></td> </tr> <tr> <?php // put render empty cells $emptycells = 0; for( $counter = 0; $counter < $startday; $counter ++ ) { echo "\t\t<td>-</td>\n"; $emptycells ++; } // renders the days $rowcounter = $emptycells; $numinrow = 7; for( $counter = 1; $counter <= $numdaysinmonth; $counter ++ ) { $rowcounter ++; echo "\t\t<td valign='top'>$counter<br />"; //do your normal mysql setup and connection calls $dbc = mysql_pconnect('xxx','xxx','xxx'); mysql_select_db('refs',$dbc); //now get stuff from a table $sql = "SELECT * FROM calendar WHERE date='$y-$m-$counter'"; $rs = mysql_query($sql,$dbc); $matches = 0; while ($row = mysql_fetch_assoc($rs)) { $matches++; echo "---------------------<br />"; echo "$row[time]"." <br /><strong>$row[gender]"." $row[visitor]"." at "."$row[home]</strong><br />"; echo "$row[ref1] "."$row[ref2] "."$row[ref3] "."$row[ref4]<br />"; } if (! $matches) { echo "---------------------"; } echo ""; echo "</td>\n"; if( $rowcounter % $numinrow == 0 ) { echo "\t</tr>\n"; if( $counter < $numdaysinmonth ) { echo "\t<tr>\n"; } $rowcounter = 0; } } // clean up $numcellsleft = $numinrow - $rowcounter; if( $numcellsleft != $numinrow ) { for( $counter = 0; $counter < $numcellsleft; $counter ++ ) { echo "\t\t<td>-</td>\n"; $emptycells ++; } } ?> </tr> </table> </body> </html> Any help to send me in the right direction would be appreciated. Thanks!
  23. I thought that might be kinda hard (if not impossible) to do...thanks anyway!
  24. Thanks for the help, but it's not quite what I was looking for. I wasn't real clear in my original post. In my text file, I want item|# of times it needs to appear in the array. So, snow|2 in the text file needs to put the word snow in the list twice and, rain|4 in the text file needs to put rain in the array 4 times. Thanks again!
×
×
  • 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.