-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
How do contain the results of this api request in one Div box.
Ch0cu3r replied to SennNathan's topic in PHP Coding Help
$response contains XML data. You need to process the xml response using simplexml. -
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>
-
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.
-
The <php should be <?php
-
2 Types of Users problem (Problem: Dont have Limitation)
Ch0cu3r replied to Edmhar's topic in PHP Coding Help
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) -
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.
-
2 Types of Users problem (Problem: Dont have Limitation)
Ch0cu3r replied to Edmhar's topic in PHP Coding Help
Change the ID and password fields to ID: <input type="text" name="eusername"> </br> Password: <input type="password" name="epassword"> -
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.
-
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.
-
session_set_cookie_params not overwriting php.ini parameter
Ch0cu3r replied to tork's topic in PHP Coding Help
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. -
2 Types of Users problem (Problem: Dont have Limitation)
Ch0cu3r replied to Edmhar's topic in PHP Coding Help
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> -
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.
-
PHP Coding help -getting variable name from variable
Ch0cu3r replied to Ramamoorthy's topic in PHP Coding Help
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. -
PHP ( 2 types of users - log in problem & Access Forbidden )
Ch0cu3r replied to Edmhar's topic in PHP Coding Help
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. -
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.
- 10 replies
-
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.
-
Change $style = ' style="color: $randColor"'; to $style = ' style="color: '.$randColor.'"';
-
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.
-
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
-
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.
-
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) )
-
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>'; }
-
PHP ( 2 types of users - log in problem & Access Forbidden )
Ch0cu3r replied to Edmhar's topic in PHP Coding Help
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 -
In that case use $user = $matches[1];