Jump to content

dolrichfortich

Members
  • Posts

    32
  • Joined

  • Last visited

Everything posted by dolrichfortich

  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')";
  4. That should be. $u=isset($_POST['u1']) ? $_POST['u1'] : ''; $p=isset($_POST['p1']) ? $_POST['p1'] : ''; isset($_POST['u1']) will return true or false and not the post variable.
  5. First, when they have reached a page that is restricted, save first the url in a session before you redirect. $_SESSION['redirect_url'] = URL_OF_THE_PAGE; Here is a site which has a tutorial on getting the current url of a page. http://www.webcheatsheet.com/PHP/get_current_page_url.php Once they successfully logged in, check first if there is a redirect variable in the session. If there is a redirect variable, get the variable first, unset the redirect_url session, then redirect using the variable. If the redirect_url is not set, just redirect directly to index.php if(isset($_SESSION['redirect_ul'])) { $redirect_url = $_SESSION['redirect_ul']; unset($_SESSION['redirect_ul']); header('Location: ' . $redirect_url); exit; } else { header('Location: index.php'); exit; }
  6. Okay, try this one. Let me know if it works for you. <?php if(!$_POST) exit; $email = $_POST['email']; //$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS'; if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )) { $error.="Invalid email address entered"; $errors=1; } if($errors==1) echo $error; else { $values = array ('name','email','phone','message'); $required = array('name','email','phone','message'); $from_email = 'abcd20@myowndomain.com'; $your_email = "abcd20@myowndomain.com"; $email_subject = "New Message: ".$_POST['subject']; $headers = "From: {$from_email}\r\nReply-To: {$from_email}"; $email_content = "New message:\n"; foreach($values as $key => $value) { if(in_array($value,$required)) { if ($key != 'subject' && $key != 'company') { if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; } } $email_content .= $value.': '.$_POST[$value]."\n"; } } if(@mail($your_email,$email_subject,$email_content, $headers)) { echo 'Message sent!'; } else { echo 'ERROR!'; } } ?>
  7. Add additional parameter on the mail function to specify the email sender. Something like this. <?php $to = 'nobody@example.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com'; mail($to, $subject, $message, $headers); ?>
  8. You can try this solution http://oohhyeah.blogspot.com/2009/01/google-currency-conversion-api.html Or this one http://www.google.com/finance/converter
  9. Try this one. $pass = isset($_GET['pass']) ? $_GET['pass']:''; $login = isset($_GET['login']) ? $_GET['login']:''; $id = isset($_GET['ID']) ? $_GET['ID']:''; if($_POST) { $pass = isset($_POST['pass']) ? $_POST['pass']:''; $login = isset($_POST['login']) ? $_POST['login']:''; $id = isset($_POST['ID']) ? $_POST['ID']:''; }
  10. You should convert the number field to varchar if you want to retain those zeros.
  11. Try the file attached. [attachment deleted by admin]
  12. Probably not because you cannot create a variable or a function using numbers only.
  13. Try this one. I wonder why the code from neil.johnson didnt work. function cname($pubid) { global $db; $company= $db->query("SELECT * FROM my_database WHERE id='$pubid'") or die(mysql_error()); $company= $db->fetch_array($company); return $company['name']; }
  14. Try adding this to check if the database class is really returning any data. function cname($pubid) { global $db; $company= $db->query("SELECT * FROM my_database WHERE id='$pubid'") or die(mysql_error()); print_r($db->fetch_array($company)); while($company= $db->fetch_array($company)) { $cname = $company['name']; } return $cname; }
  15. Hahaha. Glad I could help. Just send me a message if you need help with your money making ideas in mind. By the way, heres an explanation of the single line code I used. http://www.tuxradar.com/practicalphp/3/12/4
  16. Hahaha. By the way, heres the fix. Change this code $_SESSION['current_background'] = isset($_SESSION['background'][$_SESSION['current_background'] - 1]) ? ($_SESSION['current_background'] - 1) : count($_SESSION['background']); To this $_SESSION['current_background'] = isset($_SESSION['background'][$_SESSION['current_background'] - 1]) ? ($_SESSION['current_background'] - 1) : count($_SESSION['background'])-1; To force it to start with the first image. Use this code if(( ! isset($_SESSION['current_background'])) OR (! $_POST)) { $_SESSION['current_background'] = 0; }
  17. array($result) will not give you the data in the resource. You will need to use mysql_fetch_array or similar function to get those data. Here is a sample code. <?php $con = mysql_connect('localhost',$user,$pass)or die(mysql_error()); $selectdb = mysql_select_db($selectdb)or die(mysql_error()); $sql = "SELECT * From table"; $result = mysql_query($sql); //This loops until mysql_fetch_array returns false //which means you have reached the last row while ($row = mysql_fetch_array($result)) { print_r($row); } ?>
  18. What was the error you are getting?
  19. Oh, its you. How was your photography site? By the way, try this one. This should work. <?php session_start(); if (!isset($_SESSION['background'])) { $_SESSION['background'] = array ( "<img src='sundragon_environments/ocean/ocean1_FRAME.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME2.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME3.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME4.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME5.jpg'/>" ); } if(!isset($_SESSION['current_background'])) { $_SESSION['current_background'] = 0; } if(isset($_POST['further'])) { $_SESSION['current_background'] = isset($_SESSION['background'][$_SESSION['current_background'] + 1]) ? ($_SESSION['current_background'] + 1) : 0; } elseif(isset($_POST['back'])) { $_SESSION['current_background'] = isset($_SESSION['background'][$_SESSION['current_background'] - 1]) ? ($_SESSION['current_background'] - 1) : count($_SESSION['background']); } $currentBackground=$_SESSION['background'][$_SESSION['current_background']]; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php echo $currentBackground;?> <form action='NAVIGATION.php' method='post'> <input type="submit" value="go further" name="further" /> <input type="submit"value="Go back" name="back"/></form> </body> </html>
  20. How about this. <?php session_start(); if (!isset($_SESSION['background'])) { $_SESSION['background'] = array ( "<img src='sundragon_environments/ocean/ocean1_FRAME.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME2.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME3.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME4.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME5.jpg'/>" ); } if(isset($_POST['further'])) { $currentBackground=next($_SESSION['background']); } elseif(isset($_POST['back'])) { $currentBackground=prev($_SESSION['background']); } else { $currentBackground=$_SESSION['background'][0]; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php echo $currentBackground;?> <form action='NAVIGATION.php' method='post'> <input type="submit" value="go further" name="further" /> <input type="submit"value="Go back" name="back"/></form> </body> </html>
  21. There are many php scripts for this on the web. Try this one. http://www.merchantos.com/makebeta/php/scraping-links-with-php/
  22. Try this code. You have some missing } for your if conditions. <?php $dbserver = "localhost"; $dbuname = "vri_dev"; $dbpword = "emit098nice054"; $con = mysql_connect($dbserver, $dbuname, $dbpword); if(!$con) { die('Could not connect to the database server :' . mysql_error()); } else { echo"1.2"; //Select Database mysql_select_db("vri_inkcontrol", $con); //Get idcname $q = "SELECT idcname FROM `tbl_hosting_cname` WHERE cname='{$_POST['cname']}' AND dname='{$_POST['dname']}'"; $r = mysql_query($q); //Put idcname query into an array $r_array = mysql_fetch_assoc($r); //Store idcname result from previouse query $idcname = $r_array['idcname']; //trap duplicate records //If the number of rows returned by above query is not greater then we if(mysql_num_rows($r) == 0) { echo"2"; //Insert idcname in `tbl_hosting_cname` since id doesn't exist $q = "INSERT INTO `tbl_hosting_cname` SET cname='{$_POST['cname']}'"; mysql_query($q); //grab the cname id in `tbl_hosting_cname` $q = "SELECT idcname FROM `tbl_hosting_cname WHERE cname='{$_POST['cname']}'"; $r = mysql_query($q); //now we must grab the id cname from array $q = "SELECT idcname FROM `tbl_hosting_cname` WHERE cname='{$_POST['cname']}'"; $r = mysql_query($q); $row = mysql_fetch_assoc($r); $idcname = $row['idcname']; $r = mysql_query("SELECT * FROM `tbl_hosting_domain` WHERE cname='{$idcname}' AND dname='{$_POST['dname']}'"); if(mysql_num_rows($r) !== 1) { echo"3"; $q = "INSERT INTO `tbl_hosting_domain` (idcname, dname, ip, ns1, ns2, ftpaddress, ftpuname, ftppword, pop, smtp, webmailaddress, diskspace, bandwidth, nummailboxes, mailboxquota, numdatabases, exp) VALUES ('{$idcname}', '{$_POST['dname']}', '{$_POST['ip']}', '{$_POST['ns1']}', '{$_POST['ns2']}', '{$_POST['ftpserver']}', '{$_POST['ftpuname']}', '{$_POST['ftppword']}', '{$_POST['pop']}', '{$_POST['smtp']}', '{$_POST['webmailaddy']}', '{$_POST['adiskspace']}', '{$_POST['ambw']}', '{$_POST['amboxes']}', '{$_POST['amboxesquota']}', '{$_POST['adbases']}', '{$_POST['exp']}')"; mysql_query($q); $route = "Location: index.php?section=newaddyes"; } elseif(mysql_num_rows($r) == 1) { echo"3.2"; $q = "SELECT idcname FROM `tbl_hosting_cname` WHERE cname='{$_POST['cname']}'"; $r = mysql_query($q); $row = mysql_fetch_assoc($r); $idcname = $row['idcname']; $q = "UPDATE `tbl_hosting_domain` SET ( ip = '{$_POST['ip']}', ns1 = '{$_POST['ns1']}', ns2 = '{$_POST['ns2']}', ftpaddress = '{$_POST['ftpserver']}', ftpuname = '{$_POST['ftpuname']}', ftppword = '{$_POST['ftppword']}', pop = '{$_POST['pop']}', smtp = '{$_POST['smtp']}', webmailaddress = '{$_POST['webmailaddy']}', diskspace = '{$_POST['adiskspace']}', bandwidth = '{$_POST['ambw']}', nummailboxes = '{$_POST['amboxes']}', mailboxquota = '{$_POST['amboxesquota']}', numdatabases = '{$_POST['adbases']}', exp = '{$_POST['exp']}' WHERE cname='{$idcname}'"; $route = "Location: index.php?section=newaddyes"; } else { echo"lsr1"; $route = "Location: index.php?section=newaddno"; } } }
  23. Replace your code $query = "UPDATE CollegeFootballPicks SET User_ID = '$Current_user_id', Game_ID = '$gameF', Pick = '$pickF'"; With this code $query = "UPDATE CollegeFootballPicks SET Pick = '$pickF'" WHERE User_ID='$Current_user_id' AND Game_ID='$gameF';
  24. To return the submitted in for selectbox, the code is like this. <?php function post($fieldname, $default = '') { return isset($_POST($fieldname)) ? $_POST[$fieldname]:$default; } ?> <select name="DateOfBirth_Month"> <option <?php echo post('DateOfBirth_Month')==1?'SELECTED':''?> value="1">January</option> <option <?php echo post('DateOfBirth_Month')==2?'SELECTED':''?> value="2">February</option> </select> <select id = "DateOfBirth_Day" name="DateOfBirth_Day"> <option>Day</option> <?php for($i=1;$i<=31;$i++) { ?> <option <?php echo post('DateOfBirth_Day')==1?'SELECTED':''?>value="<?php echo $i?>"><?php echo $i?></option> <?php } ?> </select> <select id = "DateOfBirth_Year" name="DateOfBirth_Year"> <option>Year</option> <?php for($i=2010;$i>=1900;$i--) { ?> <option <?php echo post('DateOfBirth_Year')==1?'SELECTED':''?>value="<?php echo $i?>"><?php echo $i?></option> <?php } ?> </select>
×
×
  • 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.