Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Everything posted by HuggieBear

  1. I think what Jesi's trying to say is, we're not here to do it for you. If you have attempted some code already then post it here and we can point you in the right direction. OK, so are the people that visit the page registered in some way or are they just random visitors to the site? Regards Huggie
  2. Snoob, I've looked at your code and sent you a revised version. This was a simple case of overlooking something already posted. My advice would be to sloooooow down Basically after putting $myemail into a session variable $_SESSION['myemail'] and then redirecting to the login_success.php you still tried to run a query using $myemail. login_success.php has no visibility of $myemail, you needed to use $_SESSION['myemail'] Regards Huggie
  3. OK, can you send me the whole code for that page in a PM? Also, to get the syntax highlighting, use <?php as an opening tag, not just <? Regards Huggie
  4. OK, here's the code then, look at the change I made to it... <?php // start your session session_start(); // variables to connect to db here $host="************"; // Host name $username="********"; // Mysql username $password="********"; // Mysql password $db_name="*******"; // Database name $tbl_name="web_members"; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); if(!session_is_registered(myemail)){ header("location:loginotd.php"); } else{ // query string. just an example to pull all info from 'something' $sql = "select * from web_members WHERE Email='$myemail'"; // execute the query and put the result SOURCE in $result $result = mysql_query($sql) or die ("Couldn't execute $sql: " . mysql_error()); // Added error reporting // Did away with the loop as only one row is returned! $list = mysql_fetch_assoc($result); echo "blah doesnt exist" . $list['Firstname']; } // end else ?> Regards Huggie
  5. Snoob, does this query "select * from web_members WHERE Email='$myemail'" only return one result? Regards Huggie
  6. Just echo the column name... You're getting all the details from the database by using the query SELECT * FROM web_members WHERE Email='$myemail' and then assigning them with $list = mysql_fetch_assoc($result) so assuming the user's first name is in the web_members table and is called Firstname. Just use this after the query. <?php echo "Welcome " . $list['Firstname']; ?> Regards Huggie
  7. Thorpe, I like the look of this one and I'm trying to come up with a solution myself.  Can you post once you have one and I'll do the same. Regards Huggie
  8. Sure, so create an item_detail.php and pass it the id of the product in the URL, through an html link that looks something like this: [code=php:0]<a href="item_detail.php?product_id=29">View Details</a>[/code] [b]item_detail.php[/b] [code]<?php // Get the id from the URL $id = $_GET['product_id']; // Query the database for the details $sql = "SELECT * FROM details WHERE id_column = '" . $id . "'"; $result = mysql_query($sql) or die ("Unable to execute $sql: " . mysql_error()) $details = mysql_fetch_array($result, MYSQL_ASSOC); // Echo the results, these will differ depending on the ID passed to the page echo "Product ID: " . $details['id_column']; echo "Product Name: " . $details['name']; echo "Product Decription: " . $details['short_desc']; ?>[/code] Get the idea? Regards Huggie
  9. No problem, I simplified the code a little for you too. [code]<?php // Firstly check there's something in your session variable *debug* print_r($_SESSION['cart']); //makes the query easier if we put the pid's in a list $pid_string = implode("', '", array_keys($_SESSION['cart'])); print_r($pid_string); // should give us a list in the format 'id1', 'id2', 'id3' etc *debug* // OK, let's do the database stuff $connection = db_connect(); //connect $sql = "SELECT product_id, dl_link FROM products WHERE product_id IN ('$pid_string') ORDER BY product_id"; $result = mysql_query($sql) or die ("Sorry, unable to execute $sql: " . mysql_error()); // execute the query // Loop through the results array, putting the values in to a new array keyed on pid while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){   $links[$row['product_id']] = $row['dl_link']; // Here's the magic } // Lets see if the array is as we expected *debug* print_r($links); ?>[/code] Huggie
  10. Odd, that all looks OK. It may need the header type if it's being used as a cgi app which is possible. You could try adding the code i supplied to the very top of the page. Regards Huggie
  11. OK, there doesn't look like there's anything wrong with that code. Can you post the code for mod.php as that's likely what's causing the problem. Regards Huggie
  12. PHP has a few built in functions for this kind of thing, and there's also regular expressions.  Check the php manual for [url=http://uk.php.net/manual/en/function.strip-tags.php]strip_tags()[/url]. Regards Huggie
  13. You need to make sure you have the correct content-type. Normally this means outputting something like: [code]<?php // Output content type for the page header('Content-type: text/html'); ?>[/code] But without seeing any code we're not really in a position to help  :o Regards Huggie
  14. I don't know what you mean by "My login page follows me".  Maybe you could post some code for us. Regards Huggie
  15. [quote author=Snooble link=topic=124619.msg516667#msg516667 date=1170117265] if i was logged in would it be able to post the firstname and second name that are stored in the database? [/quote] On your login page once you've authenticated a user, you can assign their details into session variables, then by placing session_start() at the top of any of your other pages on your site, you can retrieve those variables using the global $_SESSION array... [b]login.php[/b] [code]<?php // Start the session session_start(); // Get my user details from the form $user = $_GET['frmUser']; $pass = $_GET['frmPass']; // My database query to authenticate the user would go here $sql = "SELECT real_name FROM users WHERE ....."; // get the idea // Process the query here with mysql_query() $result = mysql_query($sql) or die ("Unable to execute $sql: " . mysql_error()); // Put the persons real name into a session variable $details = mysql_fetch_array($result, MYSQL_ASSOC); $_SESSION['name'] = $details['real_name']; ?>[/code] Now to echo that on page two all I do is this: [b]page2.php[/b] [code]<?php // Start the session again session_start(); // Check for username if (isset($_SESSION['name'])){   echo "Welcome " . SESSION['name'] } else {   header('Location: login.php'); } ?>[/code] Regards Huggie
  16. [quote author=Snooble link=topic=124619.msg516659#msg516659 date=1170116881] I am learning... honestly. Thank you so much [/quote] My advice in that case is to always have the PHP manual open beside your code.  As far as I'm concerned, it's the best manual of any programming language I've ever worked with. The main page is here: http://uk.php.net/manual/en/index.php (UK Mirror) And from there you can type in any function name in the box at the top right of the page and be taken straight to the details of it. Regards Huggie
  17. That's pretty much it for initialising sessions, just session_start() but I'd certainly advise reading the manual. Regards Huggie
  18. You must have [url=http://uk.php.net/manual/en/function.session-start.php]session_start()[/url] at the top of every page that uses sessions.  It has to appear before anything gets output to the browser. A quick read up on [url=http://uk.php.net/manual/en/ref.session.php]PHP's Sessions[/url] should help out here Regards Huggie
  19. Functions upon functions upon functions... How long's the full code.  If it's not too huge, maybe you could post it here? Huggie
  20. Sorry, I just copied and pasted your code for that bit.  Didn't check it. Corrected the easy way! ;) Huggie
  21. ok can you confirm for me in that case, that the line that contains the code is actually in $img_text.  As your code doesn't say that! You have this... [code=php:0]<img src="http://www.xxx.com/wp-content/uploads/2007/01/593761.jpg"....[/code] I'd expect it to say this... [code=php:0]$img_text = '<img src="http://www.xxx.com/wp-content/uploads/2007/01/593761.jpg"....';[/code] Regards Huggie
  22. You're better off using something like isset() [code]<?php if (isset($_SESSION['myemail'])){   echo "Logged in as <strong>$_SESSION['fname'] $_SESSION['sname']</strong>. <br />\nClick here to log out"; } else{   echo <<<HTML   <a href="loginotd.php" target="mainpage">Login</a><br />   <a href="javascript:void window.open('register.php','Checkout','status=no, scrollbars=1, height=790, width=560')">Register</a> HTML; } ?>[/code] [b]Edit:[/b] Code corrected Regards Huggie
  23. If you have your Exchange server setup with an SMTP connector, then yes, you should be able to configure mail() to use it without any issues. Regards Huggie
  24. OK, The list() is what's causing the problem.  Comment that line out and in your $div_open variable, change $img_width to $img_src . Regards Huggie
  25. [quote author=ProjectFear link=topic=124605.msg516537#msg516537 date=1170111884] i was going to suggest timestamp to. just use time() [/quote] If you're going with timestamp, then just use mysql's now() function, don't worry about PHP's time() or microtime() functions at all. INSERT INTO table_name (unique_id) VALUES (now()) Regards Huggie
×
×
  • 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.