Jump to content

dolrichfortich

Members
  • Posts

    32
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.dolrichfortich.com

Profile Information

  • Gender
    Male

dolrichfortich's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Try this one. <?php if ($_SESSION['username']) { echo "<p><b>My Account</b><br /><br /> <a href=ah.php>Auburn Hills</a><br /> <a href=la.php>Los Angeles</a><br /> <a href=sc.php>San Carlos</a><br /> <a href=bos.php>Boston</a><br /> <a href=bna.php>Nashville</a><br /> <a href=logout.php>log out</a><br /> <a href=account.php>Account Settings</a></p>"; } ?> </p> </li> </ul> </li> <h4><span>About</span></h4> <ul> <li> <p style="margin: 0;"> This is system is in alpha stages of development...</p> </li> </ul> </li> <ul> <li></li> </ul> </div> <div id="content"> <div class="box"> <p><h3>Add New Machine</h3> <?php if ($_SESSION['username']) { echo "You are logged in as <u>".$_SESSION['username']."</u>!</p>"; } else { echo "Log In"; } ?> <form action="" method="POST"> <table border=1> <tr><td>Asset ID: *</td><td> <input type="text" name="asset_id" maxlength="10" size="10"> </td></tr> <tr><td>Location: *</td> <td> <select name="location"> <option value ="Auburn Hills"> Auburn Hills</option> <option value ="Los Angeles"> Los Angeles</option> <option value ="San Carlos"> San Carlos</option> <option value ="Boston"> Boston</option> <option value ="Nashville"> Nashville</option> </td></tr> <tr><td>Status: *</td> <td> <select name="status"> <option value ="active"> active</option> <option value ="spare"> spare</option> </td></tr> <tr><td>Type: *</td> <td> <select name="Type"> <option value ="desktop"> desktop</option> <option value ="laptop"> laptop</option> <option value ="server"> server</option> </td></tr> <tr><td>Manufacturer:</td> <td> <select name="make"> <option value ="Apple"> Apple</option> <option value ="Dell"> Dell</option> <option value ="HP"> HP</option> <option value ="IBM"> IBM</option> <option value ="Lenovo"> Lenovo</option> <option value ="Custom"> Custom</option> </td></tr> <tr><td>Model: *</td> <td> <select name="Model"> <option value ="MB Pro">MacBook Pro</option> <option value ="Mac Pro">Mac Pro</option> <option value ="Dimension D-620">Dimension D-620</option> <option value ="Dimension D-630">Dimension D-630</option> <option value ="Optiplex 745">Optiplex 745</option> <option value ="Optiplex 780">Optiplex 780</option> <option value ="Dimension M90">Dimension M90</option> <option value ="Dimension M6500">Dimension M6500</option> <option value ="Dimension E6410">Dimension E6410</option> <option value ="Dimension E6420">Dimension E6420</option> </td></tr> <tr><td>Amount of Ram:</td> <td> <select name="Ram"> <option value ="not sure"> not sure</option> <option value ="Under 1GB"> under 1GB</option> <option value ="1 GB"> 1 GB</option> <option value ="2 GB"> 2 GB</option> <option value ="3 GB"> 3 GB</option> <option value ="4 GB"> 4 GB</option> <option value ="8 GB"> 8 GB</option> <option value ="16 GB"> 16 GB</option> <option value ="24 GB"> 24 GB</option> <option value ="Above 24GB"> Above 24GB</option> </td></tr> <tr><td>Warranty:</td><td> <input type="text" name="warranty" maxlength="20" size="20"></td></tr> <tr><td>Username:</td><td> <input type="text" name="active_user" maxlength="8" size="8"></td></tr> <tr><td>Notes:</td><td> <input type="text" name="notes" maxlength="45" size="45"></td></tr> </table> <br> <input class="buttonSubmit" type="submit" name="addid" value="Add"> </form> <?php if($_SESSION['username']) { $con = mysql_connect("localhost","root","c3rb3ru5"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("gpj_asset", $con); //process the input into variables $submit = $_POST['addid']; $asset_id = strtolower(strip_tags(trim($_POST['asset_id']))); $location = strip_tags(trim($_POST['location'])); $active = strip_tags(trim($_POST['status'])); $platform = strip_tags(trim($_POST['Type'])); $make = strip_tags(trim($_POST['make'])); $model = strip_tags(trim($_POST['Model'])); $Ram = strip_tags(trim($_POST['Ram'])); $warranty = strip_tags(trim($_POST['warranty'])); $active_user = strip_tags(trim($_POST['active_user'])); $notes = strip_tags(trim($_POST['notes'])); if ($submit) { // Check for an existing asset $runThis = "SELECT * FROM assets WHERE asset_id = '$asset_id'"; //find the amount that match $count = mysql_num_rows($runThis); //Validate input $error = false; if ($count == 0) { if ( ! $asset_id OR ! $location OR ! $platform OR ! $active) { $error = "All * fields are required"; } else { //No input errors, run query $query = "INSERT INTO assets (`asset_id`, `location`, `active`, `platform`, `make`, `model`, `Ram`, `warranty`, `active_user`, `notes`) VALUES ('$asset_id','$location','$active','$platform','$make', '$model','$Ram','$warranty','$active_user', '$notes')"; $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } } } else { $error = 'Asset ID Exists!'; } //Check if any errors occured if($error !== false) { echo "<span style=\"color:red\"> {$error}</span>\n"; } else { echo "Asset Added Successfully"; } } } else echo " <form action=connect.php method=POST> <h3>Please Login <img src=\"images/0.410.gif\" /></h3> <table border=0> <tr><td>Username:</td><td> <input type=text name=username></td></tr> <tr><td>Password:</td><td> <input type=password name=password></td></tr></table> <input class=buttonSubmit type=submit name=submit value=submit></form>"; ?>
  2. You have some problem with your ordering of codes. //No input errors, run query $query = "INSERT INTO assets (`asset_id`, `location`, `active`, `platform`, `make`, `model`, `Ram`, `warranty`, `active_user`, `notes`) VALUES ('$asset_id','$location','$active','$platform','$make', '$model','$Ram','$warranty','$active_user', '$notes')"; if (!$result) { die('Invalid query: ' . mysql_error()); } $result = mysql_query($query); This would be the correct order. Execute the query first before checking if it is successful or not. Are you not getting some php errors from your code? //No input errors, run query $query = "INSERT INTO assets (`asset_id`, `location`, `active`, `platform`, `make`, `model`, `Ram`, `warranty`, `active_user`, `notes`) VALUES ('$asset_id','$location','$active','$platform','$make', '$model','$Ram','$warranty','$active_user', '$notes')"; $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); }
  3. You are using single qoutes for your table names. $query = "INSERT INTO assets ('asset_id, 'location', 'active', 'platform', 'make', 'model', 'Ram','warranty','active_user','notes') VALUES ('$asset_id','$location','$active','$platform','$make', '$model','$Ram','$warranty','$active_user', '$notes')"; Try this one and make sure you place it before you execute the query. $query = "INSERT INTO assets (`asset_id`, `location`, `active`, `platform`, `make`, `model`, `Ram`, `warranty`, `active_user`, `notes`) VALUES ('$asset_id','$location','$active','$platform','$make', '$model','$Ram','$warranty','$active_user', '$notes')";
×
×
  • 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.