Jump to content

rmmo

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Everything posted by rmmo

  1. thanks alot teynon! thats exactly what i was after! much appreciated! RMMO <SOLVED> thanks to all especially teynon
  2. should have had the $name as '$name' and $password as '$password'. so now there is no slq error but my $results variable isnt showing what i had hoped! i was hoping for a "customer_id" from my customer table but it is infact showing "Resource id #3" and i have NO IDEA where thats coming from! could it be that this is returning an array? i have no idea how to get my actual table data... i only need the one feild so that i can assign it to another variable for an insert statement! PLEASE can someone explain why this is happening?! thanks a million! in advanced RMMO
  3. ok so this code is supposed to insert data into my orders table... but first i need to find my cust_id from the customer table as it is a feild in the orders table... why isnt the sql select query working??? it just goes to my error trigger?! can anyone see where i have gone wrong? $conn = mysql_connect($host, $dbuser, $dbpass) or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db($dbname, $conn) or trigger_error("SQL", E_USER_ERROR); $name = $_SESSION['name']; $password = $_SESSION['password']; echo $name; echo $password; $checkcustid= ("select customer_id from customer where customer_name = $name and customer_password = $password"); // $insertorder = mysql_query("insert into custorder values('',''"); // echo $name, "your order has been processed below is your recipt. please printscreen this page to use as proof of purchase."; //foreach ($_POST as $value => $key) // { // echo $value, '<br/>'; // insert into table here //} $results = mysql_query($checkcustid, $conn) or trigger_error("SQL", E_USER_ERROR); echo $results; ?>
  4. thanks alot Barand! i didnt do exactly what you said but i got the idea. thanks all RMMO <SOLVED>
  5. so what will that do? i mean i need to make the insert statement run in the loop as well dont i? like so it inserts a row for each checkbox?
  6. hi have you tried the full file path? like a hyperlink would that work? just a thought. hope it helps RMMO
  7. ummm... sorry i guess the first post wasnt very clear. ill just post the form // connect to and select db $conn = mysql_connect($host, $dbuser, $dbpass) or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db($dbname, $conn) or trigger_error("SQL", E_USER_ERROR); $name = $_SESSION['name']; $password = $_SESSION['password']; if($db){ $query = "select * from product"; $result = mysql_query($query); ?> <table border bgcolor ='green'> <tr> <th>product id</th> <th>name</th> <th>description</th> <th>price ($)</th> </tr> <? while($row = mysql_fetch_array($result) ) { ?> <form method="post" action="artsonlinestorermmoorders.php"> <tr> <td><?=$row['prod_id'] ?></td> <td><?=$row['prod_name'] ?></td> <td><?=$row['prod_desc'] ?></td> <td><?=$row['prod_price'] ?></td> <td><input type="checkbox" name="<?=$row['prod_id'] ?>" value="1" /></td> </tr> <? } //end while }else die("sorry could not retreive product listings"); ?> <input type="submit" name="submit" value="order selected" /> <input name="reset" type="reset" value="clear" /> </form> thats the one with the checkboxes. now i want to make another that takes the array thats posted from there and enters each of the keys into a new insert statement. is that a bit clearer? hope so if not just tell me what bit im not making sense on. thanks again RMMO
  8. hi all right so here i go again! i have a form with checkboxes... the results are posted to the next php and they get there as an array. the data i need to go into the table is this customer_id , Credit Card Number, prod_id, No of products and the date. could some one help me figure out how to itterate through the array and pick out only the keys (prod_id) .. and have them inserted with the other info into a row in my table (ordertable)? PHULEASE! thanks in advanced! RMMO ps below is what is printed when echo the array.. with one of the boxes checked! Array ( [submit] => order selected [prod101] => 1 ) so i need to just take "prod101" and have that go into this statement insert into orders values ( '$productid', $user_id, $cc_number, $no_of_products, $sysdate) oh pps... how can i get sysdate assigned to a $VARIABLE ??? last ps promise
  9. great, that worked a treat! interesting disccusion guys.. i think you came to an agreement at the end of it... both ideas are great depending on the needs of the system... ill just store the usrnm and paswd in this case as they are the only bits i need later on. thanks to both of you! my problem is answered! so this post is <SOLVED>
  10. hi all. im trying to figure out the best way to do this: when my user enters his/her username and password into a form they are posted to the next page where they are assigned to $username and $password and then checked against the database (this all works). now i want to use these two bits of data on vitrually ever subsiquent page... is there any way to carry them over to all the other pages other than making invisible forms to post them? (i allready have forms posting other data.) if so could someone explain how i could do it. thanks very much for reading and thanks in advanced for any help you may be able to offer. RMMO
  11. hey everyone... simple question.. what did i do wrong here? can someone point out why these errors come up in the code below? errors : Notice: Undefined variable: customerid in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\artsonlinestorermmonewcustomer.php on line 18 Notice: Undefined variable: custname in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\artsonlinestorermmonewcustomer.php on line 18 Notice: Undefined variable: customeremail in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\artsonlinestorermmonewcustomer.php on line 18 Notice: Undefined variable: vnewpass in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\artsonlinestorermmonewcustomer.php on line 18 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''customer' values ( , , , )' at line 1 <?php // connect to and select db $conn = mysql_connect($host, $dbuser, $dbpass) or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db($dbname, $conn) or trigger_error("SQL", E_USER_ERROR); $insertnewcustsql ="insert into 'customer' values ($customerid , $custname , $customeremail , $vnewpass)"; if ($_POST['customer_id'] && $_POST['customer_name'] && $_POST['customer_email'] && $_POST['npassword'] && $_POST['vnewpass']) { // sanitize $customerid = mysql_real_escape_string($_POST['customer_id']); $custname = mysql_real_escape_string($_POST['customer_name']); $customeremail = mysql_real_escape_string($_POST['customer_email']); $npassword = mysql_real_escape_string($_POST['npassword']); $vnewpass = mysql_real_escape_string($_POST['vnewpass']); } else { echo "sorry couldnt get posted items"; } if($npassword == $vnewpass) { mysql_query($insertnewcustsql , $conn) or die(mysql_error()); } else { echo "you didnt enter the password the same both times"; } echo "these are your new account details" echo $customerid; echo $custname; echo $customeremail; echo $npassword; echo $vnewpass; ?> thanks in advanced RMMO
  12. ummm... well the hidden form tag didnt work out too well.... ??? i think im going to need some help sorting it out,,,, ive tried for about an hour.. i keep getting undeclared variables and when i manage to pass it the dont show the values they show... $variable name so if anyone knows how to do this could you give me a hand many thanks in advanced RMMO
  13. ok so a hidden form tag... great umm what about the two mysql queries did they look ok? and how about the sysdate question? any idea? thanks alot ag3nt42 and thanks in advanced to anyone else who may help. RMMO
  14. hi all... im back with another question... how can i do somthing complicated in a simple way? no here is my real question... i have a form on page1 it posts two variables username & password to a second page, page now on this page there is a table with checkboxes... what i want to do is to take the variables username & password from page1 as well as the results of the checkboxes from page2 to another page, page three and put them into a MYSQL query! <?php session_start(); ?> ..... HTML STUFF ...... <?php // connect to and select db $conn = mysql_connect($host, $dbuser, $dbpass) or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db($dbname, $conn) or trigger_error("SQL", E_USER_ERROR); // if there are posted vars... if ($_POST['USERNAME'] && $_POST['PASSWORD']) { // sanitize $username = mysql_real_escape_string($_POST['USERNAME']); $password = mysql_real_escape_string($_POST['PASSWORD']); // see if they are in table $query = "SELECT `customer_name`, `customer_password` FROM `customer` WHERE `customer_name` = '$username' AND `customer_password` = '$password'"; $results = mysql_query($query, $conn) or trigger_error("SQL", E_USER_ERROR); // find out how many rows returned. $rows = mysql_num_rows($results); // if something returned... if ($rows > 0) { // user/pass exist, do something, like make a session var signifying user is logged in $_SESSION['loggedin'] = true; require("artsonlinestorermmomenu.php"); echo "welcome $username"; require("artsonlinestorermmoproducts.php"); // if nothing returned... } else { if($username == 'g' & $password == 'p') { echo "welcome guest user (again please note you may only browse the site before registration"; require("artsonlinestorermmoproductsguest.php"); } else { //user/pass do not exist, do something echo "sorry your username and password did not match or you are not registered"; require("artsonlinestorermmo.php"); } } // end if..else $rows // if no username and/or pass posted... } else { echo "plase enter a username and password. If you are not a registerd user and would like to register please follow the link."; require("artsonlinestorermmo.php"); } // end if..else username/password ?> </body> </html> so i want to keep the values that are posted from up there ^. (username, password) $conn = mysql_connect($host, $dbuser, $dbpass) or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db($dbname, $conn) or trigger_error("SQL", E_USER_ERROR); if($db){ $query = "select * from product"; $result = mysql_query($query); ?> <table border bgcolor ='green'> <tr> <th>product id</th> <th>name</th> <th>description</th> <th>price ($)</th> </tr> <? while($row = mysql_fetch_array($result) ){ ?> <form method="post" action="artsonlinestorermmoorders.php"> <tr> <td><?=$row['prod_id'] ?></td> <td><?=$row['prod_name'] ?></td> <td><?=$row['prod_desc'] ?></td> <td><?=$row['prod_price'] ?></td> <td><input type="checkbox" name="<?=$row['prod_id'] ?>" value="1" /></td> </tr> <? } //end while }else die("sorry could not retreive product listings"); ?> <input type="submit" name="submit" value="order selected" /> <input name="reset" type="reset" value="clear" /> </form> </body> </html> i need the results from the checkboxes up there ^ (returns an array... i need the keys from the array (prod_id)s) then i need to put them into an insert query it would look somthing like this insert into orders values ('$customer_id', '$prod_id', 'sysdate') so that means i need to use the $username to first query the database to find its matching 'customer_id'.... so select 'customer_id', 'customer_address' from customer where 'customer_name' like '($username)'; i dunno im new to this im sure you guys can tell that... oh and is there anyway to enter that ^ (sysdate?) right so thats my problem i know its alot to ask but if you can make any sense of it all please any help would be greatly appreciated RMMO thanks in advanced.
  15. yeah that worked great.... thanks alot for that! like i said im using a ancient book... so thats my products displayed! do you have any idea how i could have checkboxes next to each row so that a user could select some rows to pass to an 'orders' page? thanks alot for all the help! RMMO
  16. Hi all, i have a table in my data base called 'product' it contains 4 columns 'prod_id','prod_name','prod_desc' and 'prod_price' so my goal is to display all rows from the table on my page in a tabular format. i have already had a stab at this... below is the code i came up with... only problem is that the table shows up with the headers only... no data... and only the cells for the headers are correct the others dont show... so does that mean there is a problem with the <td>s and <tr>s??? another thing that may be stopping the data showing is the <DBQUERY> tag... the book i got that from is UBER old... so it may be depreciated.. anyway you guys will know better than me... // connect to and select db $conn = mysql_connect($host, $dbuser, $dbpass) or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db($dbname, $conn) or trigger_error("SQL", E_USER_ERROR); if($db) { echo "<table border bgcolor ='green'>"; echo "<tr><th>prod_id<th><th>prod_name<th><th>prod_desc<th><th>prod_price</th>"; echo "<dbquery q> select * from product"; echo "<dbrow><tr><td><? q.prod_id></td><td><? q.prod_name></td><td><? q.prod_desc></td><td><? q.prod_price></td></tr>"; echo "</dbquery>"; echo "</tr>"; echo "</table>"; } else { echo "sorry could not retreive product listings"; } ?> any help would be greatly appreciated RMMO
  17. Wow thanks alot for all that help everyone the last post by Crayon Violent is the one i went with... it worked great! no i know this is probably really bad but it threw an error for the session_start() saying that the headers were allready sent.. so i commented that bit out.... will i go to PHP hell for that? anyway im going to say that this is <SOLVED> thanks again to all that helped! much appreciated! RMMO
  18. im sorry about the comment... but that wasnt the trouble... i know that an else cant have any conditions attached. thats why the comment was there..... previously i tried to use a ELSEIF.. that didnt work either... the == i didnt know about but sadly that hasnt solved it,.... the error is: Parse error: syntax error, unexpected T_ELSE in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\artsonlinestorermmologin.php on line 52 thats the line with the ELSE on it... but you could guess that from the error thanks for all the help! still not solved any more help would be greatly appreciated RMMO
  19. Hi all, well this is my first post in here i have had a read of the rules and think i get them all... i just hope im writing this in the right place. on to my problem. i have a mysql database containing information about customers that will login to my site... now without being too complicated i want to vairify if the username and password passed from my form are present in the database.. so i have used action = POST to send the values from the form and $_POST to get assign the values to variables $username and $password... i can echo them without issue. i can also carry out a query and echo the rows from the table... now what i want to do is to compare the results from the sql query and the values in $username and $password... i had a go and this below is what i came up with... ..... if($connect_mysql) { echo "connection established to MYSQL"; } else { die ("Connection could not be established with MYSQL"); } $mysql_db = mysql_select_db("artsonlinermmo"); if($mysql_db) { echo "database mounted"; } else { die("could not mount AORMMO database"); } $query = ("SELECT customer_name, customer_password FROM customer where customer_name like $username"); $results = mysql_query($query); while($row = mysql_fetch_assoc($results)) if($username = $row['customer_name']); { echo "great your a user!"; } else //(!$username == $row['customer_name']); { die("sorry not a user"); } ?> ..... now when i browse the form and submit it... i get the following error message... i gather it is about the ELSE i have up there but i have gone over it a hundred times and cant see any problem with it... any help would be greatly appreciated! thanks in advanced RMMO PS this is only day 2 of using PHP for me so im trying to keep it simple... (this is supposed to be a login page)
×
×
  • 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.