Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. It does exit, Its just this forum seems to have an issue parsing HEREDOC properly.
  2. Right. So when the user successfully logs in you create the $_SESSION['_login_id'] variable? Correct. If thats the case then you should be able to do <?php session_start(); // connect to mysql here $query = "SELECT session_user FROM product_table WHERE session_user = '{$_SESSION['_login_id']}"; $result = mysql_query($query); if($result) { // session_user doesn't match $_SESSION['_login_id'] redirect to index.php if(mysql_num_rows($result) == 0) { header('Location: index.php'); } // there is a match. Display the page else { echo 'session_user matches _login_id! Continue displaying rest of page!'; } } else { trigger_error('There is a problem with: mysql_error(), E_USER_ERROR); } ?>
  3. You may prefer to use heredoc syntax echo <<<HTML <div class="level">Edit:</div> <div class='box'> <input type="text" size="50" name="cat" value="{$cat}"/> <b><input type="button" value="+ Details" onclick="document.getElementById('rev{$clicker}').style.display='block';"/></b> </div> <br> HTML; No need to worry about what quotes you use. Just type the html as you normally would.
  4. I have no idea what you're doing. You're just confusing the hell out of me. Post your whole code here.
  5. I typed an extra ) by mistake. Line 13 corrected. elseif(isset($_SESSION['_login_id']) && $_SESSION['_login_id'] != $_GET['id'])
  6. Then you want to check to see if $_SESSION['_login_id'] is equal to $_GET['id'] at the top of your script <?php session_start(); if(!isset($_SESION['_login_id'])) { echo 'You must be logged into view this page'; } elseif(isset($_SESSION['_login_id']) && $_SESSION['_login_id'] != $_GET['id'])) { echo 'You cannot edit another users product!'; } else { // your code here for editing the product } ?>
  7. So what are you wanting the code to do? I re-read this thread and I am confused. Maybe you need to give more of an explanation of what you're trying to do.
  8. OKay,Lets see what stored in $_SESSION change your code to mysql_select_db($database_vekipman, $vekipman); $query_URUNS = "SELECT `session_user` FROM urunler"; $URUNS = mysql_query($query_URUNS, $vekipman) or die(mysql_error()); $row_URUNS = mysql_fetch_array($URUNS); $totalRows_URUNS = mysql_num_rows($URUNS); $_SESSION['session_user']=$row_URUNS['session_user']; if($_SESSION['login_id'] != $_SESSION['session_user']) { $home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/index.php'; //header('Location: ' . $home_url); echo "<pre>" . print_r($_SESSION, true) . "</pre>"; } else { echo 'Sorry but ' . $_SESSION['login_id'] . ' was equal to ' . $_SESSION['session_user']; }
  9. If you know HTML this should take you no longer than 2 seconds to throw a link in. $message .= '<a href="link here">Link Text Here</a>'; Modify that line to your needs and place it where you want the url to be
  10. The file style.css will be requested by your HTML (or specifically your web browser), not PHP. So you'd use a url <link rel="stylesheet" type="text/css" href="http://example.com/style.css" /> No matter what the url is it will request for correct file each time.
  11. I find the regulare-expressions.info site quite useful for commonly used regex patterns, such as matching email addresses http://www.regular-expressions.info/email.html
  12. You wont find an exact example of what you're trying to achive within the manual. But you are looking at the right functions to use, which was preg_replace. You'll need to use regex to convet @username to a clickable to link which takes them to the uses profile. Example code $str = 'Hello, @martin How are you?'; $str = preg_replace('~@([a-z0-9]+)~i', '<a href="http://site.com/$1">@$1</a>', $str); echo $str;
  13. In this code echo '<td><form action="rmail.php" method="post"> <input type="hidden" value="'.$email['id'].'" name="delete"><input type="image" src="/webimages/delete.png" onclick="return confirm(\'Are you sure you want to Delete?Click Ok to proceed and Delete or Cancel if you do not want to delete!\');"><a href="viewmembers.php?user='.$email['from'].'"><img src="/webimages/eye3.gif" border="0" height="25" width="30"></a></td>'; Your're not closing the form. Make sure you're outputting valid HTML code, before debugging PHP. You'll want to close the form (add </form>) after <input type="image" src="/webimages/delete.png" onclick="return confirm(\'Are you sure you want to Delete?Click Ok to proceed and Delete or Cancel if you do not want to delete!\');"> Also these lines $newvalue = mysql_query("SELECT * FROM data"); $newvalue = mysql_fetch_array($newvalue); $newvalue = $newvalue['rmailsent']; $newvalue = $newvalue-1; mysql_query("UPDATE data SET rmailsent = '$newvalue'"); Could be written as one line mysql_query("UPDATE data SET rmailsent = rmailsent-1"); You may want to add a WHERE clause to that query, otherwise ALL rows within the table will be affected. I assume you have some form of id column within the data table, which relates to the email id. Your query most probably should be mysql_query("UPDATE data SET rmailsent = rmailsent-1 WHERE email_id_field='$id'");
  14. You could use array_map, set the first parameter to 'strtolower' (including the quotes) and the second parameter to $lower_case_array.
  15. Why? They both do the same thing. Except mysql_fetch_array returns two types of arrays, an associative array (aka mysql_fetch_assoc) and an enumerated array (aka mysql_fetch_row). @dgnzcn: Can you tell us what values does $_SESSION['_login_id'] and $_SESSION['username'] hold? My guess is $_SESSION['_login_id'] contains a number, which is assigned to the user when they are logged in? And $_SESSION['username'] is the logged in users username? If that is the case you cannot compare a number to a string if($_SESSION['_login_id'] != $_SESSION['session_user']) { $home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/index.php'; header('Location: ' . $home_url); } else { echo 'Sorry but the session died.'; exit(); } PHP will not know the relationship between the login id and the username. Therefore that if statement will always return false, and thus the error message is shown. Why are you needing to compare the login id with the username?
  16. You have filled in your form first and submitted it? If it's still not inserting then change mysql_query($q); to mysql_query($q) or trigger_error("Error with query: $q<br />Error: " . mysql_error(), E_USER_ERROR); Your code is correct and should be inserting something into your database. In MySQL Front make sure you refreshing the table view each time you add a new record.
  17. The query string seperator is an ampersand (&) not a question mark. However you shouln't be passing messages over the url. You should prehaps pass the error message using a session or cookie. If you're going to pass messages over the url then you should atleast urlencode it.
  18. The table is not set to read only. It is most probably the mysql account you've logged into MySQL with, which doesn't have the necessary privileges for inserting records into the table.
  19. Your query is invalid. The correct way to insert values into a mysql table would be INSERT INTO table_name VALUES ('value1', 'value2' etc). or INSERT INTO table_name SET field1='value1, field2='value2', etc So to insert the username/password into the signup table. You'd write the query as $q="INSERT INTO signup VALUES ('$usr', '$pass')"; To perform the query you'd pass the variable $p to mysql_query. mysql_query($q); if you query is not working, then run mysql_error to get the error message from the last executed query. mysql_query($q) or trigger_error("Error with query: $q<br />Error: " . mysql_error(), E_USER_ERROR);
  20. You are coding the drop down menu incorrectly. Correct syntax for a drop down is <select name="menu_name"> <option value="value1">value1</option> <option value="value2">value2</option> <option value="value3">value3</option> ... etc ... <select> Notice you only give the opening <select> tag a name. Each <option></option> has a unique value given to it. You can retrieve the selected value, by using either $_GET['menu_name'] or $_POST['menu_name'] (depending your forms submit method). Corrected code echo "Product Model: <select name=\"product_model\">"; // printing the list box select command while($rows = mysql_fetch_array($result)) {//Array or records stored in $nt echo "<option value=\"{$rows['product_id']}\">{$rows['product_model']}</option>"; /* Option values are added by looping through the array */ } echo "</select><br />"; Please use or tags when posting code. It'll make reading your code alot easier
  21. What? You'll have to provide more information than that.
  22. This topic has been moved to Beta Test Your Stuff!. http://www.phpfreaks.com/forums/index.php?topic=307377.0
  23. From the screenshot you posted of MySQL Front it is showing that you have created a database called signup with a table called username, which contains 3 fields called id, username and password However in your code you're using the database realestate, mysql_select_db("realestate",$db) and adding the username/password to the Customer table. $q="insert into Customer Values('$usr','$pass')" You sure this is the correct database/table to use?
  24. I haven't duplicated those files. I setup the file structure as you posted earlier Download the attached zip. Extract to your root folder. Go site.com/visuallaza to test [attachment deleted by admin]
  25. I just tested it and it worked. I went to site.com/areas/area1/ I asummed thats how you called index.php in areas/area1
×
×
  • 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.