Jump to content

SoulAssassin

Members
  • Posts

    34
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

SoulAssassin's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. If I understand correctly, you want a dynamic form which gets values from the database as you select them in you form? If this is true, then you should use something like Ajax to get the values of selected, and Update each one separately. http://www.ajaxtutorial.net/
  2. Should I not maybe put the something in the <form>? <form action="" method="post" onSubmit="return confirm('Confirm Delivery?');">
  3. Ok, I have played with it, tried this: <input type="button" name="deliverconf" value="Deliver" onclick="return confirm('Confirm Delivery?');"> <? if(isset($_POST['deliverconf'])) { echo "Form Sumitted"; } ?> and it still doesn't work. Please guys, doesn't anyone have a suggestion?
  4. I have a form button that I would like to have a confirmation pop up before submit like this: <input name="delivered_id" type="hidden" value="id21" /> <input type="button" name="deliverconf" value="Deliver" onclick="temp = window.confirm('Confirm Delivery?');"> The confirm message with Ok and Cancel pops up, but it seems like my temp" variable gets set. Then I have do this, with no success: <? if(isset($_POST['deliverconf'])) { $self = $_SERVER['php_self']; $delivered_id = $_POST['delivered_id']; $deliverconf = $_POST['deliverconf']; echo "$delivered_id"; echo "$deliverconf"; } ?> This "if(isset($_POST['deliverconf']))" doesn't even happen. I also tried "if(isset($_POST['temp']))", but nothing. Why can that be? I also thought it might work like this: <? if ($temp) { echo "$temp"; } ?> Also no success, and even if it does, will I loose my POST values. Any suggestions, or a better method to get a confirmation message?
  5. Why are doing your form in PHP format? It just makes it much easier to do it in HTML. I also don't really understand why you put form values in "$username". But this is what I would have done <? if(isset($_POST['Submit'])) { if ($_POST['username'] == "" or $_POST['password'] == "" ) { echo "Please complete Username and Password"; } else { $self = $_SERVER['PHP_SELF']; $username = $_POST['username']; $password = md5($_POST[password]); //password encryption $mysql_host="localhost"; $mysql_user="nikon"; $mysql_pass="lol"; $mysql_dbname="nutrition_db"; $conn = @mysql_connect( "localhost", "nikon", "lol" ) or die("Could not connect to MySQL"); $db = @mysql_select_db( "nutrition_db", $conn ) or die("Could not select database"); $sql = "insert into users (username, password) values ('$username', '$password')"; $result = @mysql_query( $sql, $conn ) or die("Could not execute query"); if($result) { echo( "New user $username added" ); } } } ?> Please enter all new user details... <form action="<? $self ?>"method="post"> Username:<input type="text" name="username" value=""> <br> Password: <input type="text" names="password" value=""> <br> <input type="submit" value="Submit" name="Submit"> </form>
  6. You might also want to try adding MYSQL_ASSOC in there like this: <? while ($user_array = mysql_fetch_array($result, MYSQL_ASSOC)) { ?>
  7. I don't understand your problem. If you Insert the values in a table, you can do a query to find out how many results for each. 1st Page <form name="form1" method="post" action="results.php"> <table width="300" border="0" cellspacing="0" cellpadding="0"> <tr> <td><input type="radio" name="reason" value="CarAccident"></td> <td>CarAccident</td> </tr> <tr> <td><input type="radio" name="reason" value="WorkInjury"></td> <td>Work Injury</td> </tr> <tr> <td><input type="radio" name="reason" value="ColdFlu"></td> <td>Cold/Flu</td> </tr> <tr> <td><input type="radio" name="reason" value="Other"></td> <td>Other</td> </tr> <tr> <td><input type="radio" name="region" value="Scotland"></td> <td>CarAccident</td> </tr> <tr> <td><input type="radio" name="region" value="Wales"></td> <td>Work Injury</td> </tr> <tr> <td><input type="radio" name="region" value="Ireland"></td> <td>Cold/Flu</td> </tr> <tr> <td><input type="radio" name="region" value="England"></td> <td>Other</td> </tr> </table> <p> <input type="submit" name="Submit" value="Submit"> </p> </form> results.php <? if(isset($_POST['Submit'])) { $reason = $_POST['reason']; $region = $_POST['region']; $conn=mysql_connect("localhost","username","password") or die("Could not connect to MySQL"); $db=mysql_select_db("yourdb",$conn) or die("Could not Select database"); $result = mysql_query("Insert into yourtable(reason, region) values('$reason', '$region')"); if($result) { echo "Entry Added:"; echo "<br>"; echo "Reason - $reason:"; echo "<br>"; echo "Region - $region:"; } } ?> Then I'm sure you know how to do a SELECT from your database.
  8. I have tried it now with register globals on and off. the problem lies here: <? $adminid = $_SESSION['userid']; $adminuser = $_SESSION['user_name']; $adminuser_email = $_SESSION['user_email']; $adminuser_tel = $_SESSION['user_tel']; if(isset($_POST['Amend'])) { $userid = $_POST['userid']; $user_name = $_POST['user_name']; $user_email = $_POST['user_email']; $user_tel = $_POST['user_tel']; echo "user name - $user_name"; echo "<br>"; echo "admin name - $adminuser"; echo "<br>"; echo "<br>"; echo "$user e-mail - $user_email"; echo "<br>"; echo "admin e-mail - $adminuser_email"; echo "<br>"; echo "<br>"; echo "user tel - $user_tel"; echo "<br>"; echo "admin tel - $adminuser_tel"; echo "<br>"; } ?> <form name="form" method="post" action=""> Edit User: <table> <tr> <td width="11%">User Name</td> <td width="23%">Password</td> <td width="22%">E-Mail</td> <td width="20%">Tel</td> </tr> <tr> <td><strong><? echo $row['user_name'];?></strong></td> <td><input type="user_pass" name="user_pass" value=""></td> <td><input type="user_email" name="user_email" value="<? echo $row['user_email']; ?>"></td> <td><input type="user_tel" name="user_tel" value="<? echo $row['user_tel']; ?>"></td> </tr> </table> <input type="hidden" name="user_name" value="<? echo $row['user_name'];?>"> <input type="hidden" name="userid" value="<? echo $row['userid'];?>"> <input type="Submit" name="Amend" value="Update"> </form> How does it happen that $adminuser_email ends up being the same as $user_email ? It happens with all the fields.
  9. I've done that, and it most definitely changes the Session after form has been posted, and a new user selected for edit. Ok, I'm now posting print screens, maybe it makes more sense I'm printing it with the print_r($_SESSION);, so you guys can see the real session values. This is when I land on the page. The Sessions are all correct. Selected User1 for edit, and change tel. When for POST, see how the Session changes in the print, but on the left, the Session still shows correctly. When Selecting Use2 for edit, see how the Session on left also changes I've been sitting with this problem for 3 days, and it's delaying development. Can someone please check the process sequence, and maybe suggest another place to define my Sessions, or a different method of storing it? I'm obviously over complicating it in my own head. Thanks
  10. No problem, please remember to mark the thread as RESOLVED.
  11. No, you have a unnecessary "$" in there. <td>{$row['racername']}</td><td>{$row['averageet']}</td><td>{$row['car']}</td><td>${$row['entry']}</td>
  12. The problem was here <td>{$row['racername']}</td><td>{$row['averageet']}</td><td>{$row['car']}</td><td>${$row['entry']}</td>
  13. There you go <?php session_start(); include 'config.php'; if(isset($_POST['Submit'])) { $self = $_SERVER['php_self']; $_SESSION['username'] = $_POST['username']; $_SESSION['password'] = $_POST['password']; } if($_SESSION['username'] == 'prem' && $_SESSION['password'] == '123456') { $sql = "SELECT * FROM tourney"; $query = mysql_query($sql); ?> <table width="539"> <tr> <th width="148">Racer Name</th> <th width="138">Average ET</th> <th width="143">Car</th> <th width="90">Entry</th> </tr> <? while($row = mysql_fetch_array($query)) { ?> <tr>"; <td><? $row['racername']; ?></td> <td><? $row['averageet']; ?></td> <td><? $row['car']; ?></td> <td><? $row['entry']; ?></td> </tr> <? } ?> </table> <? } else { ?> <form action="<? $_SERVER['php_self']; ?>" method="post"> <table width="31%" border="1"> <tr> <td>user name:</td> <td><input type="text" name="username"></td> </tr> <tr> <td>password:</td> <td><input type="text" name="password"></td> </tr> </table> <input type="submit" value="Submit" name="Submit"> </form> <? } ?>
  14. The one I posted definitely works, you just need to change all the relevant fields to your Database fields.
  15. This is a little tricky. Go read up on Ajax. There are some very easy quick tutorials. It's basically Java running with PHP, so it automatically runs when a selection has been made. Dynamic Forms doing mysql_query without having to refresh, or submit. try this link http://www.ajax-tutorials.com/tutorial-list/
×
×
  • 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.