Jump to content

JCS1988

Members
  • Posts

    26
  • Joined

  • Last visited

    Never

Contact Methods

  • AIM
    Iceboy1701
  • Website URL
    http://www.jcsimmersdesigns.com
  • Yahoo
    Flip71704

Profile Information

  • Gender
    Male
  • Location
    Phoenixville, PA

JCS1988's Achievements

Member

Member (2/5)

0

Reputation

  1. I am using an HTML form that posts the data to confirm.php which I created. There the users sees a confirmation screen and the data is mailed out to my email address. All of this works great, except for when the user navigates directly to the confirm.php, skipping over the form page. The form is mailed out with all fields blank. I did get a solution to this problem awhile ago but it no longer works. I'm guessing the newer PHP doesn't support it. What I want is for PHP to check and see if data exists. If no data is present the user should be redirected to index.html, if there is data they will see the confirmation and the email will be sent to me. The first few lines are what originally would check for data and if none was present they would be directed to index.html. I just need something that will provide the same function as this one did before. Thanks! <?php if (sizeof($_POST)==0) { header("Location:index.html"); } else { $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/")); // Checkbox handling $field_14_opts = $_POST['field_14'][0].",". $_POST['field_14'][1].",". $_POST['field_14'][2]; mail("jessesimmers@gmail.com","Website Form","Form data: First Name: " . $_POST['field_1'] . " Last Name: " . $_POST['field_2'] . " Address: " . $_POST['field_3'] . " City: " . $_POST['field_4'] . " State: " . $_POST['field_5'] . " Zip Code: " . $_POST['field_6'] . " Home Phone: " . $_POST['field_7'] . " Cell Phone: " . $_POST['field_8'] . " Email: " . $_POST['field_9'] . " Best Time To Reach You: " . $_POST['field_10'] . " Best Day To Reach You: " . $_POST['field_11'] . " Number of Windows: " . $_POST['field_12'] . " I Am Interested In: $field_14_opts "); ?>
  2. I fixed it but it would only work in IE still. I just got rid of the set cookie and instead used a session that works in both browsers. Thanks for the help!
  3. so ")" being the problem, whats the solution to the problem? What has to be done for this to work correctly?
  4. Removing the ")" gives me an error. Parse error: syntax error, unexpected ';' in /whs2fs1_2us4_2/jcs5325aii/domains/jcs5325.aisites.com/public_html/member-index.php on line 6 This is what I have <?php session_start(); require_once('auth.php'); $customer_id = $_SESSION['SESS_CUSTOMER_ID']; setcookie("currentcustomer", $customer_id, time()+3600*24, '/', 'www.jcs5325.aisites.com'; ?>
  5. Thanks for the reply. I tried that but I get a syntax error. Parse error: syntax error, unexpected ',' in /whs2fs1_2us4_2/jcs5325aii/domains/jcs5325.aisites.com/public_html/member-index.php on line 6 The modified code: <?php session_start(); require_once('auth.php'); $customer_id = $_SESSION['SESS_CUSTOMER_ID']; setcookie("currentcustomer", $customer_id, time()+3600*24), '/', 'www.jcs5325.aisites.com'; ?>
  6. Hi, I am trying to set a cookie but it only ever shows up if I am using IE6. Is there something I'm missing? Thanks in advance. setcookie("currentcustomer", $customer_id, time()+3600*24);
  7. I had figured that wasn't set right, the " and ' are always confusing to me. Now I made the changes but the cookie will not show up using IE or Firefox, although it does work if I add just a regular value to the cookie such as $customer_id = "idValue"; Is this because the session is created AFTER the setcookie function? Here is the code I have now, I added your code in place of mine. But look down where the session is created, does this have something to do with why the cookie wont set? <?php //Start session session_start(); $customer_id = $_SESSION['SESS_CUSTOMER_ID']; setcookie("currentcustomer", $customer_id, time()+3600); //Connect to mysql server $link=mysql_connect("data.jcs5325.aisites.com","jcs5325aii_pho","203633"); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db=mysql_select_db("jcs5325aii_photography"); if(!$db) { die("Unable to select database"); } //Sanitize the value received from login field //to prevent SQL Injection if(!get_magic_quotes_gpc()) { $username=mysql_real_escape_string($_POST['username']); }else { $username=$_POST['username']; } //Create query $qry="SELECT customer_id FROM users WHERE username='$username' AND password='$password'"; $result=mysql_query($qry); //Check whether the query was successful or not if($result) { if(mysql_num_rows($result)>0) { //Login Successful session_regenerate_id(); $customer=mysql_fetch_assoc($result); $_SESSION['SESS_CUSTOMER_ID']=$customer['customer_id']; session_write_close(); header("location: member-index.php"); exit(); }else { //Login failed header("location: login-failed.php"); exit(); } }else { die("Query failed"); } ?>
  8. I have the cookies working now, they do show up but the one variable I need isn't displaying properly. Most likely because I have it set wrong, any idea on how I would do something like this? This is the session I am creating: $_SESSION['SESS_CUSTOMER_ID']=$customer['customer_id']; $customer_id = "'$_SESSION['SESS_CUSTOMER_ID']'"; setcookie("currentcustomer", $customer_id, time()+3600); <?php //Start session session_start(); $customer_id = "'$_SESSION['SESS_CUSTOMER_ID']'"; setcookie("currentcustomer", $customer_id, time()+3600); //Connect to mysql server $link=mysql_connect("data.jcs5325.aisites.com","jcs5325aii_pho","203633"); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db=mysql_select_db("jcs5325aii_photography"); if(!$db) { die("Unable to select database"); } //Sanitize the value received from login field //to prevent SQL Injection if(!get_magic_quotes_gpc()) { $username=mysql_real_escape_string($_POST['username']); }else { $username=$_POST['username']; } //Create query $qry="SELECT customer_id FROM users WHERE username='$username' AND password='$password'"; $result=mysql_query($qry); //Check whether the query was successful or not if($result) { if(mysql_num_rows($result)>0) { //Login Successful session_regenerate_id(); $customer=mysql_fetch_assoc($result); $_SESSION['SESS_CUSTOMER_ID']=$customer['customer_id']; session_write_close(); header("location: member-index.php"); exit(); }else { //Login failed header("location: login-failed.php"); exit(); } }else { die("Query failed"); } ?>
  9. Here I am again, another minor problem I have. My site uses sessions, but I have one particular script that requires a user ID from a cookie called $currentcustomer. I don't have the knowledge to go through and modify the code and use sessions so I figure I'll just set the cookie it wants and be done with it. Here is my script, after logging in the user is taken here to verify the provided login info. Thanks in advance! This is the session it's creating for the customer id, I'd like a cookie version as well, I'm just not sure where to place it and how to call it in properly. $_SESSION['SESS_CUSTOMER_ID']=$customer['customer_id']; Here is the entire page <?php //Start session session_start(); //Connect to mysql server $link=mysql_connect("host","login","password"); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db=mysql_select_db("jcs5325aii_photography"); if(!$db) { die("Unable to select database"); } //Sanitize the value received from login field //to prevent SQL Injection if(!get_magic_quotes_gpc()) { $username=mysql_real_escape_string($_POST['username']); }else { $username=$_POST['username']; } //Create query $qry="SELECT customer_id FROM users WHERE username='$username' AND password='$password'"; $result=mysql_query($qry); $customer_id="SELECT customer_id FROM users WHERE username='$username' AND password='$password'"; //Check whether the query was successful or not if($result) { if(mysql_num_rows($result)>0) { //Login Successful session_regenerate_id(); $customer=mysql_fetch_assoc($result); $_SESSION['SESS_CUSTOMER_ID']=$customer['customer_id']; session_write_close(); header("location: member-index.php"); exit(); }else { //Login failed header("location: login-failed.php"); exit(); } }else { die("Query failed"); } ?>
  10. Looks simple enough, how could I replace this code with that. I see the code I have refers to a rowset, Dreamweaver set it all up for me. <?php echo $row_userSet['card_number']; ?>
  11. I am designing an eCommerce site as a class project, I have gotten most of it done by now but I am just working on the last few steps. Right now I am working on a page that displays an overview of the customers order. It pulls all the information from the database and displays it, but for the billing info section I just wanted to print out the card info and then the number like **** **** **** 5784. I'm sure most of you have seen this done on other shopping web sites, so I was curious as to how I would go about doing something like that. The number is stored in the "users" table under the field "card_number". Their is no encryption as of right now, I am keeping things simple since this isn't going to be an actual site. Right now on the confirmation page I have a recordset in Dreamweaver that calls in all information from the users table, so it will be there already I guess I just need to change how it's printed. Any help would be great, thanks in advance!
  12. Yep, first method worked perfect. Thanks!
  13. I did a lot of searching and found similar problems, but the situations were a bit different than mine and I was unable to get it work with the codes I found. I'm sure there is a very simple solution to this, but I don't know it so maybe someone can help me out. I have a page that sets a session $_SESSION['SESS_CUSTOMER_ID']=$customer['customer_id']; On the next page I would like to retrieve the customer id from the session and use it in a query to select all of the information about the customer in the table. I have a recordset setup in Dreamweaver to post all of the information into a dynamic table, I just seem to be having trouble getting that session variable to be read. Here is a sample of what it would look like, I just need to figure out how to insert the session. $query_userSet = "SELECT * FROM users WHERE customer_id = $_SESSION['SESS_CUSTOMER_ID'];
  14. So I have another problem and decided to come back here since everyone is always so helpful. I have a database setup with all my products, users, and orders. You can browse the products and add them to a cart, everything works fine on that part. But I am not sure how to complete the actual check out process. I have a user account system where users can register, then login. Certain pages require a visitor to be logged in, so when the users logs in a session is created. I believe the session is storing 'customer_id', which is located in the customers table under each customers unique ID. The script is below, i'm not sure what exactly is being stored. If you click checkout on this page http://jcs5325.aisites.com/cart.php it will take you to a submit order form that I got from my text book files. The lesson didn't involve user accounts, it just explained how to setup the cart and then type in the info at the last minute. I want this submit order page to use the stored customer_id and access the customer info (first_name, last_name, email, etc) and display it along with the items and total, just like any other confirmation page you would see. In other words I want to completely do away with that form that asks for the information and have the page get the users info that's already in the database. This is the code from my text book, the page can be seen from the link above. <?php session_start(); require("opendbo.php"); require("displaycartfunction.php"); $today = Date("Y-m-d", time()); if ((isset($HTTP_COOKIE_VARS)) || (isset($HTTP_SESSION_VARS)) || (isset($HTTP_GET_VARS))) { extract ($HTTP_COOKIE_VARS); extract ($HTTP_SESSION_VARS); extract ($HTTP_GET_VARS); extract ($HTTP_POST_VARS); extract ($HTTP_SERVER_VARS); } reset ($HTTP_COOKIE_VARS); reset ($HTTP_SESSION_VARS); reset ($HTTP_GET_VARS); reset ($HTTP_POST_VARS); reset ($HTTP_SERVER_VARS); if (!@$submitconfirm) { print ("Please give information for ordering or confirm information present.<br>"); print ("<form action=\"$PHP_SELF\" method=post><br>"); $ofname=""; $olname=""; $obilling=""; $oemail=""; if (@$currentcustomer) {$query="SELECT * from customers where customer_id=$currentcustomer"; $result=mysql_db_query($DBname,$query,$link); $Num_past = mysql_num_rows($result); if ($Num_past>0) { $obilling=mysql_result($result,0,"billing"); $ofname=mysql_result($result,0,"fname"); $olname=mysql_result($result,0,"lname"); $oemail=mysql_result($result,0,"emailaddress"); print ("<input type=hidden name=oldcustomer value=TRUE>"); print("<br>INFO OKAY <input type=\"radio\" name=\"choices\" value=\"OKAY\" CHECKED >"); print ("<br>CHANGE MY INFO <input type=\"radio\" name=\"choices\" value=\"CHANGE\" >"); print ("<br>NEW CUSTOMER <input type=\"radio\" name=\"choices\" value=\"NC\"><br>"); } } print ("First Name <input type=text name='fname' value='".$ofname."'><br>"); print ("Last Name <input type=text name='lname' value='".$olname."'><br>"); print ("Billing information <input type=text name='billing' value='".$obilling."'><br>"); print ("E mail address <input type=text name='email' value='".$oemail."'><br>"); print ("<input type=hidden name='submitconfirm' value=TRUE>"); print ("<input type=submit name='submit' value='SUBMIT/CONFIRM INFORMATION'>"); print ("</form>"); } else { if (!@$oldcustomer) { $query="INSERT INTO customers VALUES ('0','".$fname; $query=$query."','".$lname."','".$billing."','".$email."','X')" ; // X for pass now $result=mysql_db_query($DBname, $query,$link); //need error handling. $currentcustomer=mysql_insert_id(); setcookie("currentcustomer",$currentcustomer); //sets permanent cookie } //end if not old customer--need to insert into db and create cookie else { // old customer. Update db just in case changes were made if (@$choices=='CHANGE') { $query="UPDATE customers set fname='".$fname ; $query = $query . "', lname='".$lname."', billing='".$billing; $query = $query . "', emailaddress='".$email ."' where id=$currentcustomer"; mysql_db_query($DBname,$query,$link); } else if (@$choices=='NC') { $query="INSERT INTO customers VALUES ('0','".$fname; $query=$query."','".$lname."','".$billing."','".$email."','X')" ; // X for pass now $result=mysql_db_query($DBname, $query,$link); //need error handling. $currentcustomer=mysql_insert_id(); $duration = 90 * 24 * 60* 60; //90 days setcookie("currentcustomer",$currentcustomer, time()+$duration); //sets long term } //end if changed to new customer } print("Welcome, $fname <br>"); print ("Today is $today <br>\n"); print ("Here is your order.<hr>"); displaycart(); print ("<hr> We are billing it using the following information: <br> $billing<br>"); $query = "INSERT INTO orders VALUES ('0', '"; $query = $query . $currentcustomer."', '".$today."', 'set',".$totalprice.")"; mysql_db_query($DBname, $query, $link); $orderid=mysql_insert_id(); foreach ($cart as $key=>$value) { $product_id = substr($key, 1); $query="INSERT INTO ordereditems VALUES ('".$orderid."','".$product_id."',".$value.")"; mysql_db_query($DBname,$query,$link); } //ends the foreach /* // uncomment this section to troubleshoot modifications echo "<pre>"; print_r($HTTP_SESSION_VARS); print_r($HTTP_SESSION_VARS['cart']); echo "</pre>"; */ //session_unregister('cart'); unset($HTTP_SESSION_VARS['cart']); unset($HTTP_SESSION_VARS['items']); unset($HTTP_SESSION_VARS['totalprice']); //session_unregister('totalprice'); //session_unregister('items'); unset($cart); unset($items); unset($totalprice); session_destroy(); } //ends handling of form -- the else clause on if submitconfirm ?> </body> </html> This is the page that confirms the users login information, and stores it in a session for access to the private pages. I assume that whatever information this script stores can be used to pull up the customer information during the checkout. <?php //Start session session_start(); //Connect to mysql server $link=mysql_connect("data.jcs5325.aisites.com","jcs5325aii_pho","203633"); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db=mysql_select_db("jcs5325aii_photography"); if(!$db) { die("Unable to select database"); } //Sanitize the value received from login field //to prevent SQL Injection if(!get_magic_quotes_gpc()) { $username=mysql_real_escape_string($_POST['username']); }else { $username=$_POST['username']; } //Create query $qry="SELECT customer_id FROM users WHERE username='$username' AND password='$password'"; $result=mysql_query($qry); //Check whether the query was successful or not if($result) { if(mysql_num_rows($result)>0) { //Login Successful session_regenerate_id(); $member=mysql_fetch_assoc($result); $_SESSION['SESS_CUSTOMER_ID']=$member['customer_id']; session_write_close(); header("location: member-index.php"); exit(); }else { //Login failed header("location: login-failed.php"); exit(); } }else { die("Query failed"); } ?>
×
×
  • 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.