Jump to content

randydg

Members
  • Posts

    45
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

randydg's Achievements

Member

Member (2/5)

0

Reputation

  1. Correction at the end of addcount.php: <form method="POST" action="<?=$PHP_SELF;?>"> Add Count from<br /> Enter Device Name: <input type="text" name="addnew"> <input type="submit" name="submitadd" value="SUBMIT"/> </form>
  2. I am having an issue. I have a code that works fine, but I want to remove a link within a script to another page and bundle it within the main page script so it doesn't have to go to another page. Basicly I want it to post to itself and delete a line out of mysq limit 1. Currently the script looks up the items from the sql database and posts the count of them and next to it has a link with a add 1 or remove 1. that goes to another script that works fine, just want to add it to the one bellow. I know how to do it with a form & script, but since the link/image is already in a script, I am not sure what to do. Index.php: <?php include 'connect.php'; $query="SELECT * FROM inventory WHERE `Device` = 'item1' "; $result=mysql_query($query); $num=mysql_numrows($result); if ($num> 0){ $id=mysql_result($result,$i,"Id"); $name=mysql_result($result,$i,"Name"); $discription=mysql_result($result,$i,"Discription"); $cost=mysql_result($result,$i,"Cost"); $retail=mysql_result($result,$i,"Retail"); $amount=mysql_result($result,$i,"Amount"); $device=mysql_result($result,$i,"Device"); print "<tr>"; print "<td bgcolor='#00ff00'>$num</td>"; print "<td>item 1 name</td>"; print "<td>item 1 discription</td>"; print "<td><a href='addcount.php'><img src='addcount.png'></a></td>"; print "<td><a href='deletecount.php'><img src='RenderedImage.png'></a></td>"; print "</tr>"; }else{ print "<tr>"; print "<td bgcolor='#FF0033'>0</td>"; print "<td>item 1 name</td>"; print "<td>item 1 discription</td>"; print "<td><a href='addcount.php'><img src='addcount.png'></a></td>"; print "<td>Nothing to Delete</td>"; print "</tr>"; } ?> addcount.php: <?php if (isset($_POST['submitadd'])) { $addnew = trim(stripslashes($_POST['addnew'])); include 'connect.php'; $query="SELECT `id`,`device` FROM `inventory`"; $result=mysql_query($query); $num=mysql_numrows($result); $sql = "INSERT INTO inventory VALUES('','','','','','','$addnew')"; $result = mysql_query($sql); if (!$result) { die('Invalid query: '.mysql_error()); } print "$addnew added successfully.<br />"; } ?> <form method="POST" action="<?=$PHP_SELF;?>"> ADD New:<br /> Enter Device ID: <input type="text" name="addnew"> <input type="submit" name="su'submitadd'value="SUBMIT"/> </form> These work fine separatly, but I was really wanting to combine them into 1 script, but the link to add/delete needs to be where it currently is in index.php or it will screw up the tables. Thanks for any advice
  3. Alright... I will read up on it but for now i need to get this code working for my office. The following code will display the name in the name field but not pulling up any of the other data for it like address.. www.blabla.com/index?name=Randy Does put Randy in the Name field and the rest of the code will submit and save Randy in the name field.. this is a step closer. I just need it to push the name into the mysql and result info like address... <table width="800" border="1"> <tr> <td colspan="5"><img src="image001.JPG" width="661" height="215"> </td> </tr> <tr> <td width="38%" rowspan="2" valign="top"><p><strong>Name or Company:</strong> <p>Name: <input name="name" type="text" id="name" value=" <?php $name = $_GET['name']; include 'connect.php'; $query="SELECT * FROM `sheets` WHERE `name` = '$name'";; $result=mysql_query($query); $num=mysql_numrows($result); $n=0; while ($n < $num) { $name=mysql_result($result,$i,"name"); $address=mysql_result($result,$i,"address"); $n++; }; echo "$name"; echo "$address"; ?> " size="20">
  4. What function is www.blabla.com/index?name=name called? I'm trying to create a script that does the following: Address bar: www.blabla.com/index?name=Randy Website: Name: (text box fills in name i put above (index?name=Randy) but while it puts the name in it also searches the mysql database on table soandso for that name and also fills in Address,city,state,zip Like so: $query="SELECT * FROM `soandso` WHERE `name` = $name"; $result=mysql_query($query); $num=mysql_numrows($result); $n=0; while ($n < $num) { $name=mysql_result($result,$i,"name"); $address=mysql_result($result,$i,"address"); $city=mysql_result($result,$i,"city"); $state=mysql_result($result,$i,"state"); $zip=mysql_result($result,$i,"zip"); $phone=mysql_result($result,$i,"phone"); $n++; };
  5. This code works on the login part of the script with no problem. its after im logged in. Its not displaying the results into the form. Index.php login first page <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="checklogin.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Member Login </strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="username" type="text" id="username"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="password" type="text" id="password"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Login"></td> </tr> </table> </td> </form> </tr> </table> Login script verify user & password the db info is from a connect.php file <?php ob_start(); include 'connect.php'; // Connect to server and select databse. mysql_connect("$host", "$dbusername", "$dbpassword")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Define $myusername and $mypassword $username=$_POST['username']; $password=$_POST['password']; // To protect MySQL injection (more detail about MySQL injection) $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("username"); session_register("password"); header("location:login_success.php"); } else { echo "Wrong Username or Password"; } ob_end_flush(); ?> Everything to this point is working. Its this next part that doesnt. The Next script gets the session info from the last script above. This script is called login_success it is called from above when you successfuly logged in <? session_start(); if(!session_is_registered(username)){ header("location:index.php"); } include 'connect.php'; //$_SESSION['username'] = $_GET; $username = $_GET['username']; $query="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'"; $result=mysql_query($query); ?> <html> <body> <p>Login Successful</p> <form name="form" method="POST" action="<?=$PHP_SELF;?>"> Name: <input type="text" name="name" value="<?php echo $result[name]?>"/> <br> Username: <input type="text" name="username" value="<?php echo $result[username]?>"/> <br> <input type="submit" value="submit"> </form>
  6. I had it somewhat working, where it posted the address just had trouble updating it. and as far as pulling the database, its the common way.
  7. Ok here is what im trying to do: 1. drop down list pulled from mysql database. 2. after you select the name in the drop down list below the drop down list it should show the address. 3. if you select another name in the drop down list it should update the address Here is the code what am I doing wrong? the drop down menu works but it doesnt post the address thanks, Randy <?php //Get Name/Company out of database $db = mysql_connect("ip","user","pass") or die("Couldn't connect"); mysql_select_db("database",$db) or die("Couldn't select database"); $query="SELECT * FROM `customers`"; $result=mysql_query($query); $num=mysql_numrows($result); echo "<span class=\"style4\"></span><select name=\"name\" id=\"name\">"; $i=0; while ($i < $num) { $techname=mysql_result($result,$i,"name"); $address=mysql_result($result,$techname,"address"); $techid=mysql_result($result,$i,"id"); echo "<option value=$techid>$techname</option>"; $i++; }; echo "<option value=\"NA\">Other</option>"; echo "<option value=\"-\" selected>-</option> </select>"; echo "<p>Address:"; echo "$address"; //Get address out of database ?>
  8. this new code doesnt give an error, but doesnt post anything either. not sure where im going wrong. with the form code in search.php and this code in lookup.php. <? if (isset($_POST['submitnew'])) { $name2 = trim(stripslashes($_POST['name'])); $theidyouspecify = $_POST['id'];// define this as the id you specify $db = mysql_connect("host","user","pass") or die("Couldn't connect"); mysql_select_db("worksheets",$db) or die("Couldn't select database"); //$sql = "SELECT FROM customers WHERE name='$theidyouspecify'"; //Get Customer Data from datebase from $customerid $query="SELECT * FROM `customers` WHERE name='$theidyouspecify'"; $result=mysql_query($query); $name=mysql_result($result,$i,"name"); echo "$name"; } } ?> oops, sorry didnt mean to double post.wont happen again.
  9. Couldn't execute query. No results display also in the code it has if(is_numeric($_POST['name'])) { Is there anyway to change this to if blank or just skip the if and just use the post part? thanks P.s. This code is supose to search for customers by name in the database. Database = worksheets table get info from = customers inside customers is field called name. its supose to search in the name field for a name that is typed in the search field Hope this helps
  10. First off im not a very good scripter. Second i'm trying to get this to do a mysql search on a database. Any help? Thanks <form name="name" method="POST" action="<?=$PHP_SELF;?>"> Enter Name to lookup <input name="name" type="text" id="name" size="50" /> <input type="submit" name="submit" /> </form> <?php if(isset($_POST['submit'])){ if(is_numeric($_POST['name'])) { $theidyouspecify = $_POST['name'];// define this as the id you specify }else{ $error[] = 'Id must be numeric.'; } // no error, so run the query if(!$error){ $db = mysql_connect("host","user","pass") or die("Couldn't connect"); mysql_select_db("worksheets",$db) or die("Couldn't select database"); $sql = "SELECT FROM customers WHERE name='$theidyouspecify'"; if(!mysql_query($sql)){ $error[] = 'failed to lookup worksheets table<br />'; }else{ $error[] = 'lOOKUP completed<br />'; } } } // get results // $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for //echo "<p>You searched for: "" . $var . ""</p>"; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["1st_field"]; echo "$result"; ?> <div id="error"> <?php $error[]=''; foreach($error as $value){ echo $value; } ?>
  11. I fixed this myself by adding this code to the validateform.php <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title> signup</title> <meta http-equiv="refresh" content="3;url=thankyou.php"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#ffffff" text="#000000"> <div> <center> <br><h1>Your message has been sent</h1> </center> </div> </body> </html>
  12. problem is it doesnt send the mail. it says it sent it but never get the email.
  13. signup.php <?php srand((double)microtime()*1000000); // Run the random number seed through the MD5 function $seed_string = md5(rand(0,9999)); // Chop the random string down to 5 characters // This is the validation code we will use $val_string = substr($seed_string, 17, 5); ?> Signup</h1> <form action="validateform.php" method="post"> <table border="0" bgcolor="#ececec" cellspacing="5"> <tr> <td width="353">First Name</td> <td width="197"><input type="text" size="10" name="fname"></td> </tr> <tr> <td>Last Name</td> <td><input type="text" size="10" name="lname"></td> </tr> <tr> <td>Phone Number</td> <td><input type="text" size="30" name="number"></td> </tr> <tr> <td>Street Address</td> <td><input type="text" size="30" name="address"></td> </tr> <tr> <td>City,State,zip</td> <td><input type="text" size="30" name="area"></td> </tr> <tr> <td>Username/Email address (3-16 char)</td> <td><input type="text" size="30" name="email"></td> </tr> <tr> <td>Password (3-16 char)</td> <td><input type="text" size="30" name="password"></td> </tr> <tr> <td>Email Filter* $1.50</td> <td><input type="text" size="5" name="filter"></td> </tr> <br> <tr> <td>*Email Filer protects you against spam & virus.</td> </tr> <tr> <td valign="top">Comments</td> <td><textarea name="comments" rows="6" cols="30"></textarea></td> </tr> <tr> <td> <div align="center">Type in the validation code number. (case sensitive)<br> <!-- <img src="verify.jpg" height="40" width="200" alt="validation image" /><br> --> <?php echo $val_string ?> </div></td> <td><input name="random" type="text" value=""> </td> </tr> <tr> <td></td> <td><input type="submit" value="Send"> </td> </tr> </table> <input name="validation" type="hidden" value="<?php echo $val_string ?>" </form> validateform.php <?php if ($_POST['validation'] == trim($_POST['random'])){ ?> <? $my_email = "email@domain.com"; $continue = "www.somethinng.com/thankyou.php"; $errors = array(); // Remove $_COOKIE elements from $_REQUEST. if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}} // Check all fields for an email header. function recursive_array_check_header($element_value) { global $set; if(!is_array($element_value)){if(preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i",$element_value)){$set = 1;}} else { foreach($element_value as $value){if($set){break;} recursive_array_check_header($value);} } } recursive_array_check_header($_REQUEST); if($set){$errors[] = "You cannot send an email header";} unset($set); // Check referrer is from same site. if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";} // Check for a blank form. function recursive_array_check_blank($element_value) { global $set; if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}} else { foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);} } } recursive_array_check_blank($_REQUEST); if(!$set){$errors[] = "You cannot send a blank form";} unset($set); // Display any errors and exit if errors exist. if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;} if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");} // Build message. function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");} $message = build_message($_REQUEST); $message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL."New customer."; $message = stripslashes($message); $subject = "**Service"; $headers = "From: " . $_REQUEST['email']; ?> Your message has been sent </a> <? mail($my_email,$subject,$message,$headers); } else { echo "Please go back and get validated."; } ?>
×
×
  • 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.