Jump to content

poperann

New Members
  • Posts

    2
  • Joined

  • Last visited

poperann's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hello. I started to edit database of someone else and I came a cross this.... thing which I'm guessing that it suppose to edit multiple entry in one click of button(or something) I cannot figure what he was thinking, but I was told to make it work... (Problem) I'm not a website person who can do php.... I can read and understand some what. Please help me to see what I can do. ______________________________________ <?php //Set session and password requirement session_start(); //start session if (!isset($_SESSION['agent']) OR ($_SESSION['agent'] != md5($_SERVER['HTTP_USER_AGENT']) )){ require_once ('../includes/login_functions.inc.php'); //$url = absolute_url(); header("Location: /info/login.php"); exit(); } $page_title = 'Browse Contacts'; //include ('../includes/header.html'); ?> <head> <title>Browse Contacts</title> <style type="text/css"> <!-- body { background-color: #AEEBFF; } #navigation table tr td a strong { color: #36F; } #navigation table { color: #36F; } #navigation4 form h2 { color: #0303FC; } font { color: #0303FC; } .font1 { color: #F00; font-size:24px } .font2 { font-size: 24px; font-family: "Book Antiqua"; font-weight: bold; } .font { text-align: center; } --> </style> </head> <body> <input type="button" value="Browse Home" onclick="window.location.href='edit.php'" /> <input type="button" value="Add a Contact" onclick="window.location.href='../contact/contacts1.php'" /> <?php // This page displays and handles a form for inserting records into the expense_categories table. // Create an HTML table: echo '<table border="2" width="90%" cellspacing="2" cellpadding="2" align="center"> <tr align="center" valign="top"> <td align="center" valign="top"><b>ID #</b></td> <td align="center" valign="top"><b>Submit</b></td> <td align="center" valign="top"><b>First Name</b></td> <td align="center" valign="top"><b>Last Name</b></td> <td align="center" valign="top"><b>GC1</b></td> <td align="center" valign="top"><b>GC2</b></td> <td align="center" valign="top"><b>GC3</b></td> <td align="center" valign="top"><b>L1-C1</b></td> <td align="center" valign="top"><b>L1-C2</b></td> <td align="center" valign="top"><b>L1-C3</b></td> <td align="center" valign="top"><b>L1-C5</b></td> <td align="center" valign="top"><b>L2-C1</b></td> <td align="center" valign="top"><b>L2-C2</b></td> <td align="center" valign="top"><b>L2-C3</b></td> <td align="center" valign="top"><b>L2-C5</b></td> </tr> '; // Include the MySQL information: require_once ('../../mysqldb.php'); //handle the form if (isset($_POST['submitted'])) { ini_set('display_errors', 1); error_reporting (E_ALL | E_STRICT); //track success //$problem = FALSE; $errors = array(); $gc1 = mysqli_real_escape_string($dbc, trim($_POST['gc1'])); $gc2 = mysqli_real_escape_string($dbc, trim($_POST['gc2'])); $gc3 = mysqli_real_escape_string($dbc, trim($_POST['gc3'])); $l1c1 = mysqli_real_escape_string($dbc, trim($_POST['l1-c1'])); $l1c2 = mysqli_real_escape_string($dbc, trim($_POST['l1-c2'])); $l1c2 = mysqli_real_escape_string($dbc, trim($_POST['l1-c3'])); $l1c2 = mysqli_real_escape_string($dbc, trim($_POST['l1-c5'])); $l2c1 = mysqli_real_escape_string($dbc, trim($_POST['l2-c1'])); $l2c2 = mysqli_real_escape_string($dbc, trim($_POST['l2-c2'])); $l2c3 = mysqli_real_escape_string($dbc, trim($_POST['l2-c3'])); $l2c5 = mysqli_real_escape_string($dbc, trim($_POST['l2-c5'])); if (empty($errors)) { //make the update query $q = "UPDATE contacts SET gc1='$gc1', gc2='$gc2', gc3='$gc3', l1-c1='$l1c1', l1-c2='$l1c2', l1-c3='$l1c3', l1-c5='$l1c5', l2-c1='$l2c1', l2-c2='$l2c2', l2-c3='$l2c3', l2-c5='$l2c5', WHERE contacts_id = $contacts_id LIMIT 1"; //echo $q; //run the query $r = @mysqli_query ($dbc,$q); //if it ran ok if ($r) { echo '<h2>Thank you.</h2> <p>Your contact information is added.</p><p><br /></p>'; } else { //if it did not run ok //public message echo '<h2>System Error.</h2> <p class="error">Your contact information could not be posted. Please try again later.</p>'; //debugging message echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p>'; } //run the query $rs = @mysqli_query($dbc,$qs); //if it ran ok if ($rs) { echo '<h2>Thank you.</h2> <p>Your information is added.</p><p><br /></p>'; echo '<p> <a href="http://Website.org">website.org </a></p>'; } else { //if it did not run ok //debugging message echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p>'; } //end of if ($r) //close the db connection mysqli_close($dbc); exit(); } else { //report the errors echo '<h2>Error</h2> <p class="error">The following errors occured:<br />'; //print the errors foreach ($errors as $msg) { echo " - $msg<br />\n"; } echo '</p><p><font color="green">Please try again.</font></p><br /> <font color="red">Press the browsers back button above to retain form data</font></p>'; } // endo of if (empty($errors)) IF //close the db connection mysqli_close($dbc); echo '<p> <a href="contact.html">Contact Main</a></p>'; echo '<p> <a href="http://website.com">website</a></p>'; }//end main submit conditional //create the query to populate the browse table $query2 = 'SELECT * FROM contacts ORDER BY contacts_id'; if ($r = mysqli_query($dbc, $query2)) { //run the query //retrieve and print while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { echo ' <form action="grade_editer.php" method="post"><ul> <tr align=\"center\" valign=\"top\"> <td> <input type="text" name="l1" value="' . $row['contacts_id'] . '" size="3" maxlength="25"/></td> <td> <input type="submit" name="submit" value="Submit" /></input></td> <td> <input type="text" name="l1" value="'. $row['first_name'] . '" size="6" maxlength="25"/></td> <td> <input type="text" name="l1" value="' . $row['last_name'] . '" size="6" maxlength="25"/></td> <td> <input type="text" name="l1" value="' . $row['gc1'] . '" size="10" maxlength="25"/></td> <td> <input type="text" name="l2" value="' . $row['gc2'] . '" size="10" maxlength="25"/></td> <td> <input type="text" name="l3" value="' . $row['gc3'] . '" size="10" maxlength="25"/></td> <td> <input type="text" name="l4" value="' . $row['l1-c1'] . '" size="10" maxlength="25"/></td> <td> <input type="text" name="l5" value="' . $row['l1-c2'] . '" size="10" maxlength="25"/></td> <td> <input type="text" name="l1" value="' . $row['l1-c3'] . '" size="10" maxlength="25"/></td> <td> <input type="text" name="l2" value="' . $row['l1-c5'] . '" size="10" maxlength="25"/></td> <td> <input type="text" name="l3" value="' . $row['l2-c1'] . '" size="10" maxlength="25"/></td> <td> <input type="text" name="l4" value="' . $row['l2-c2'] . '" size="10" maxlength="25"/></td> <td> <input type="text" name="l5" value="' . $row['l2-c3'] . '" size="10" maxlength="25"/></td> <td> <input type="text" name="l1" value="' . $row['l2-c5'] . '" size="10" maxlength="25"/></td> </tr> </form>'; } } else { //if the query didn't run print '<p style="color: red;">Could not retrieve the data because:<br />' . mysqli_error() . ' .</p><p>The query being run was: ' . $q. '</p>'; } //count the number of records $num = @mysqli_num_rows($r); echo "There are $num records.\n"; mysqli_close($dbc); ?> </table> <p></p> <input type="button" value="Browse Home" onclick="window.location.href='edit.php'" /> <input type="button" value="Add a Contact" onclick="window.location.href='../contact/contacts1.php'" /> </body> </html>
×
×
  • Create New...