Jump to content

cadac

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

cadac's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I've attached a screenshot of the page im try to populate the selected dropdown names. All I want now is to populate that members record into those textboxes as I have an update script ready to go. If you can help you would make my day Thanks
  2. Thanks for the advice, i've managed it using a slightly different piece of code but gets the result i need. Just need to figure out to display single record on the same page without refreshing :/ <?php include ('includes/connect.php'); $query = "select member_id, firstname, lastname from members ORDER BY firstname asc"; $result = mysql_query ($query) or die (mysql_error()); echo "<td><b>Select Member: </b></td> <td><SELECT name=\"member-list\">"; if (mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { echo "<option value='".$row['member_id']."'>".$row['firstname']." ".$row['lastname']."</option>"; } } echo "</SELECT></td>"; ?>
  3. I am trying to figure out how to display member records after selecting it from the box. I've got the dropdown box working which retrieves the members name but cannot figure out how to populate that members details on the same page? I'm using php/mysql and although I want to display the records I also want a user to update that record aswell, creating it for administrators to update accounts? Any help would be appreciated I've researched that ajax or javascript might be helpful but not totally familiar with them.
  4. Solved, took some concentration finding out what was wrong. The checkbox value wasn't declared so it was processing it correctly <?php require_once('includes/config.php'); $sql="SELECT * FROM members ORDER BY member_id"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="413" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td colspan="5" bgcolor="#FFFFFF"><strong>Delete a Member</strong> </td> </tr> <tr> <td width="48" align="center" bgcolor="#FFFFFF">#</td> <td width="42" align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td width="129" align="left" bgcolor="#FFFFFF"><strong>First Name</strong></td> <td width="152" align="left" bgcolor="#FFFFFF"><strong>Last Name</strong></td> </tr> <?php while($rows=mysql_fetch_assoc($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['member_id']; ?>"></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['member_id']; ?></td> <td align="left" bgcolor="#FFFFFF"><? echo $rows['firstname']; ?></td> <td align="left" bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="left" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <? // Check if delete button active, start this if(isset($_POST['delete'])){ $checkbox=$_POST['checkbox']; for($i=0;$i<count($checkbox);$i++){ $id = $checkbox[$i]; $sql = "DELETE FROM members WHERE member_id='$id'"; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ } } mysql_close(); ?> </table> </form> </td> </tr> </table>
  5. Thanks, worked this time Notice: Undefined variable: delete in /home/upckayju/public_html/members/admin/delete-member.php on line 102 I've looked at this and its the submit button which i changed to this: if(isset($_POST['delete'])){ but this still didn't delete a row?
  6. I can view my php.ini file but have no control over my apache server
  7. Hi, I need some help figuring out my problem. I currently have a script that retrieves records from a mysql database, then has checkboxes to enable to delete a record? Any help where I might be going wrong as it displays, but doesn't delete?? Thanks <?php require_once('includes/config.php'); $sql="SELECT * FROM members ORDER BY member_id"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="413" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td colspan="5" bgcolor="#FFFFFF"><strong>Delete a Member</strong> </td> </tr> <tr> <td width="48" align="center" bgcolor="#FFFFFF">#</td> <td width="42" align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td width="129" align="left" bgcolor="#FFFFFF"><strong>First Name</strong></td> <td width="152" align="left" bgcolor="#FFFFFF"><strong>Last Name</strong></td> <td width="152" align="left" bgcolor="#FFFFFF"><strong>Email</strong></td> </tr> <?php while($rows=mysql_fetch_assoc($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['member_id']; ?>"></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['member_id']; ?></td> <td align="left" bgcolor="#FFFFFF"><? echo $rows['firstname']; ?></td> <td align="left" bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="left" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <? // Check if delete button active, start this if($delete){ for($i=0;$i<$count;$i++){ $id = $checkbox[$i]; $sql = "DELETE FROM members WHERE member_id='$id'"; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete-member.php\">"; } } mysql_close(); ?> </table> </form> </td> </tr> </table>
  8. I thanks for replying, tried that and the displayed when echoed but trying to post back to the form, no luck
  9. I have managed to create an update script that allows a user to submit changes to their details but I need help to finish of the code. I'm using sessions to login in members, here is my update.php code. After while($member = mysql_fetch_array($result)) { I would like to retrieve the new values entered by them to be displayed back to the previous form which uses $_SESSION to hold their information when they previously login. Any suggestions or ideas, as I think it's to do with clearing the session but unfamiliar on how to proceed. <?php include("config.php"); mysql_connect("$dbhost","$dbuser","$dbpass") or die(mysql_error()); mysql_select_db("$dbname") or die(mysql_error()); $id= mysql_real_escape_string($_POST['member_id']); $fname= mysql_real_escape_string($_POST['firstname']); $lname= mysql_real_escape_string($_POST['lastname']); $address= mysql_real_escape_string($_POST['address']); $town= mysql_real_escape_string($_POST['address2']); $county= mysql_real_escape_string($_POST['county']); $postcode= mysql_real_escape_string($_POST['postcode']); $telephone= mysql_real_escape_string($_POST['telephone']); $mobile= mysql_real_escape_string($_POST['mobile']); $username= mysql_real_escape_string($_POST['login']); $email=mysql_real_escape_string($_POST['email']); $id= $_POST['member_id']; $sql="UPDATE members SET firstname='$fname', lastname='$lname', address='$address', address2='$town', county='$county', postcode='$postcode', telephone='$telephone', mobile='$mobile', login='$username', email='$email' WHERE member_id='$id' LIMIT 1"; $result=mysql_query($sql) or die ("Error: ". mysql_error(). " with query ". $sql); $query = "SELECT * FROM members WHERE member_id = '$id'"; $result = mysql_query($query) or die(mysql_error()); while($member = mysql_fetch_array($result)) { } ?>
  10. I'm trying, think i'm putting the wrong code in. Where should I be putting the session variable? I have attached my login-exec.php file, i've been tweaking the last bit of code and trying to use it for the update? Personally, apart from that no idea how to rectify this.. <?php // connect to your MySQL database here require_once "config2.php"; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); // the values you want to change to $id = "1"; $fname = $_POST['firstname']; $lname = $_POST['lastname']; $address = $_POST['address']; $address2 = $_POST['address2']; $county = $_POST['county']; $postcode = $_POST['postcode']; $email = $_POST['email']; $telephone = $POST['telephone']; $login = $_POST['login']; // Build sql command to update just one record or "row" $sqlCommand = "UPDATE members SET firstname='$fname', lastname='$lname', address='$address', address2='$address2', county='$county', postcode='$postcode', telephone='$telephone', email='$email', login='$login' WHERE member_id='$id' LIMIT 1"; // Execute the query here now $query = mysql_query($sqlCommand) or die (mysql_error()); // Replace sql command to Select the data now $sqlCommand = "SELECT firstname, lastname, address, address2, county, postcode, email, telephone, login FROM members WHERE member_id='$id' LIMIT 1"; $query = mysql_query($sqlCommand) or die (mysql_error()); ?? $_SESSION['SESS_FIRST_NAME'] = $fname; $_SESSION['SESS_LAST_NAME'] = $lname; $_SESSION['SESS_ADDRESS'] = $address; $_SESSION['SESS_ADDRESS2'] = $address2; $_SESSION['SESS_COUNTY'] = $county; $_SESSION['SESS_POSTCODE'] = $postcode; $_SESSION['SESS_EMAIL'] = $email; $_SESSION['SESS_TELEPHONE'] = $telephone; $_SESSION['SESS_MOBILE'] = $mobile; $_SESSION['SESS_LOGIN'] = $login; header("location: ../index.php"); ?? ?> [attachment deleted by admin]
  11. Thanks, how would i got about resetting the session and the database, do I use the session_unset() would i have to declare my values again? - still learning lol
  12. Oops forgot to put the code in tags! Also forgot to say that the members are stored in a session until the browser closes. Ideally, i'd like for them to update their details on the myprofile.php page without going to another page if that is possible? Thanks
  13. I am still quite new to php and mysql but i've managed to setup a login system, where a member can register and login to our website. Once they have logged in they can view the secure section of the site and also view their profile. This profile stores the information that relates to the database, ie personal details etc. I am able to retrieve the data using php and display it in a form using the echo commands but I want my members to be able to update their information if necessary. I have tried many solutions to no avail. I have started an update script in which once the form is submitted the data is stored successfully into the database but i don't know how to retrieve that data and display it on the profile page again where they submitted their new information. Hope this all makes sense. Here is my php code: <?php // connect to your MySQL database here require_once "config2.php"; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); // the values you want to change to $id = "1"; $fname = $_POST['firstname']; $lname = $_POST['lastname']; $address = $_POST['address']; $address2 = $_POST['address2']; $county = $_POST['county']; $postcode = $_POST['postcode']; $email = $_POST['email']; $telephone = $POST['telephone']; $login = $_POST['login']; // Build sql command to update just one record or "row" $sqlCommand = "UPDATE members SET firstname='$fname', lastname='$lname', address='$address', address2='$address2', county='$county', postcode='$postcode', telephone='$telephone', email='$email', login='$login' WHERE member_id='$id' LIMIT 1"; // Execute the query here now $query = mysql_query($sqlCommand) or die (mysql_error()); // Replace sql command to Select the data now $sqlCommand = "SELECT firstname, lastname, address, address2, county, postcode, email, telephone, login FROM members WHERE member_id='$id' LIMIT 1"; $query = mysql_query($sqlCommand) or die (mysql_error()); ?? ?> I know the code isn't the best thought out but it works, just can't get the information they entered back to the previous form Any help would be great appreciated ) [attachment deleted by admin]
×
×
  • 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.