Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. $response contains XML data. You need to process the xml response using simplexml.
  2. Because when you click the Search link you are redirecting the user to the api <script type="text/javascript"> function ftest(){ window.location="http://world.needforspeed.com/SpeedAPI/ws/game/nfsw/driver/"+document.getElementById('name').value +document.getElementById('name1').value; }</script>
  3. Dont use setcookie() to affect the actual session cookie. If you want to rename the session cookie use session_name() before you call session_start(). If you want to stop the session call session_destroy(). You cannot delete the cookie, you can only make it invalid. If the session is destroyed any session values are also cleared.
  4. The <php should be <?php
  5. You need to change the ID and password form fields to what I suggested and then run the login query else{ $query = "SELECT * FROM tbl_account WHERE LogUsername='".$eusername."' AND LogPassword = '".$epassword."' AND type = '".$logintype."'"; // run query and set sessions etc } The code provided by alpine is just an example, it is not fully working code. You need execute the query above for it do anything, then you add your own logic in to redirect the user to correct page based on the users login type (employee or administrator)
  6. The query used in user_data() function will only work if the $_SESSION['userid'] variable contains the id value for the logged in user. Check that this variable is set correctly when the user logs in.
  7. Change the ID and password fields to ID: <input type="text" name="eusername"> </br> Password: <input type="password" name="epassword">
  8. Because PHP code is parsed on the server when the .php file is requested. Browsers can only parse client side code such as html, javascript and css.
  9. Don't know why you have change your code from what you had. All you needed to do is replace the while loop with my code and then pass $_POST['categoryId'] variable to the add_hproject() function. The problem with your code above is with the query. Values used in queries need to be wrapped in quotes $categoryId = mysql_query("SELECT categoryId FROM `projectCategory` WHERE categoryName = '$cat'"); And mysql_query does not return the categoryId only the result resource. You need to use one of the mysql_fetch_* functions or mysql_result to get the categoryId value from the query.
  10. the session.cookie_* settings only affect the PHP session cookie that is created with the session_start() function. Those settings have no effect on cookies set using setcookie() This setcookie('hello', '', time(), '/', '.name.com'); sets a cookie called hello and is immediately expired. To make it expire 75 seconds later you need to set the expire time param to time()+75 session_set_cookie_params do override the default settings defined in the php.ini. You should be able to verify this using session_get_cookie_params before and after changing the cookie params.
  11. Yes, that should work. However I'd change it to this <?php include '../../core.php'; // if the user is not logged in OR they are logged in but they are not part of administration, then redirect to index.php if(!isset($_SESSION['login']) || (isset($_SESSION['type']) && $_SESSION['type'] != 'ADMINISTRATION')) { header('Location:Webpage/index.php'); exit; // stop the script } // load the admin page ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="../css/main.css"/> </head> <body> This is Admin. <a href="../../logout.php">Log Out!</a> </body> </html>
  12. Get the category id and name from the database when you make the options list and set the id as the value for the options $category=mysql_query("SELECT categoryName, categoryId FROM `projectCategory`"); while($row = mysql_fetch_array($category)) { $options .="<option value=\"".$row['categoryId']."\">" . $row['categoryName'] . "</option>"; } When the form is submitted $_POST['categoryId''] will contain the category id for the selected category.
  13. PHP does have a feature called variable variables. Which is where you use a value from one variable to define the name of another variable. Your javavscript example is using the value of the disqus_shortname variable and concatenating it into the string defined for dsq.src which is not the same thing as the problem you'e describing. You could do this in db.php <?php $varone_1234 = "1234th variable" $varone_1234_string = "this is the 1234 th line"; /* and more 100 variables related to varone_1234*/ ... $latest = '1234'; // define the latest variable number // variable variables used below $varone_latest = ${'varone_'.$latest} $varone_latest_string = ${'varone_'.$latest.'_string'} ?> But if you are storing data this way you are better of using a database.
  14. Is that the full code for loginform.php and adminloginform.php? In both files you need to include core.php and connect.php in order for 1) the sessions to work and 2) for the login code to be able to query the database. The only times you include these files is in indes.php. I didn't realise loginform.php had two forms. The action attribute for admin login should be set to adminloginform.php but the employee login form needs be set to either loginform.php or just leave it empty.
  15. yes this will work with multiple users accessing the site at the same time. This very forum uses php sessions. The name of the cookie can be changed, PHPSESSID is just the default name. If wish to rename the cookie name to something else then call session_name() before you start the session. session_start() sets the necessary cookie headers each time the function is called. If you want to override the default cookie params, then you need to call session_set_cookie_params() before the session has started.
  16. Change the user_data function to function user_data($userid) { $data = array(); $userid = (int)$userid; $func_num_args = func_num_args(); $func_get_args = func_get_args(); if($func_num_args > 0) { unset($func_get_args[0]); $fields = '`' . implode('', $func_get_args) . '`'; // check the query executed. mysql_query returns false if there is an error if(($result = mysql_query("SELECT '$fields' FROM users WHERE userid = '$userid'")) !== false) { // check that the query did actually return any results if(mysql_num_rows($result)) { return mysql_fetch_assoc($result); // return the result } // query didn't return any results else { echo 'user_data() query returned no results!'; } } // qeuery has failed find out why using msyql_error(); else { echo 'user_data() query has failed - ' . mysql_error(); } } return false; } It should echo out an error message about why the user_data() function is not returning any data.
  17. Change $style = ' style="color: $randColor"'; to $style = ' style="color: '.$randColor.'"';
  18. As in a live usb key for a linux distro? Basically what ever capacity your usb key is minus the size of the burned .iso image. I believe most image burners will tell the maximum size you can set for the persistent data.
  19. You never said that in your first post, so I didn't know that I dont use wordpress but try replacing <?php the_tags('Tags: ', ', ', '<br />'); ?> with <?php $rand = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'); $tags = get_tags(); $html = '<div class="post_tags">'; foreach ( $tags as $tag ) { $tag_link = get_tag_link( $tag->term_id ); $randColor = '#'.$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)]; $style = ' style="color: $randColor"'; $html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'{$style}>"; $html .= "{$tag->name}</a>"; } $html .= '</div>'; echo $html; ?> get_tags() reference code http://codex.wordpress.org/Function_Reference/get_tags
  20. For some reason you are not connected to mysql properly in profile.php. Does any other page on your site connect to the database? Is it just profile.php that outputs these errors?
  21. The variable $_POST['utilizadores'] will contain the selected value when the form has been submitted. The snippet of code I posted should have selected the same item when the form was submitted.
  22. you can use trim $user = trim($matches[1], '"'); Or change your regex to only match the text within the quotes if ( preg_match('/u":"([a-z0-9_]+)"}/i', $html,$matches) )
  23. You need to check if the posted value is the same as the value you're adding to the list, then you can set the selected attribute to the option. while(($row = mysql_fetch_array($query))!== false) { $selected = (isset($_POST['utilizadores']) && $row['user_id'] == $_POST['utilizadores']) ? ' selected' : ''; echo '<option value="'.$row["user_id"].'"'.$selected.'>'.$row["first_name"].' '.$row["last_name"].'</option>'; }
  24. You are getting the error in the second screenshot because the variable $current_file doesn't exist. <form action="<?php echo $current_file ?>" method="POST"> If your submitting the form to itself then use an empty action attribute
  25. In that case use $user = $matches[1];
×
×
  • 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.