-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
No need for regex use parse_url $url = 'http://blah.domain.com/directory/INFINITA/76/98/23'; $urlPath = parse_url($url, PHP_URL_PATH); // get the path from the url $segment = explode('/', trim($urlPath, '/')); // explode the path into segments echo $segment[1]; // get the second segment INFINITA
-
PHP needs to be configured to use an SMTP server in order to send emails. You need to edit the php.ini to configure this. I believe XAMPP comes with sendmail. Read this to configure PHP to use sendmail http://www.apachefriends.org/f/viewtopic.php?f=16&p=173315#p173315 If not then stop using mail() and use PHPMailer and configure it to use your email service provider SMTP server instead.
-
You need to escape the quotes for the href value $eventprnt = 'onclick="window.location.href =\'index.php?myurl ='.$item->id.'\'"';
- 3 replies
-
- open.locationopen.window
- onclick
-
(and 2 more)
Tagged with:
-
The form is not scrolling the page. It is because when the form is submitted you are reloading the page. The browser wont remember where in the page you where before the form was submitted. You try adding an achor point. Try changing <form method="post" action=""> to <a id="form"></a> <form method="post" action="#form"> That way when the form is submitted the browser should scroll down to the form.
-
Did you look here first before posting http://docs.ckeditor.com/#!/guide/dev_installation
-
Yes. You'd format the query like $registerquery = mysql_query("UPDATE users SET Forename='$newforename', Surname='$newsurname', Address='$newaddress', Telnumber='$newtelnumber' WHERE Username = '$username'");
-
If you want to set the user_level to 1 where user_id is between 7 and 35 then use UPDATE `users` SET `user_level`=1 WHERE `user_id` >= 7 AND `user_id` <= 35 >= means greater than or equal to <= means less than or equal to Alternatively you could use UPDATE `users` SET `user_level`=1 WHERE `user_id` BETWEEN 7 AND 35
-
You'd perform a join SELECT film.film_id, film.title, film.language_id, language.name AS language FROM film JOIN language ON language.language_id = film.language_id
-
That is all possible with the function I linked to in my previous post. There many tutorials out there for gd text effects. You will need to sit down and learn how to use this function.
-
Change your code to <?php session_start(); include_once "base.php"; //connects to database if(isset($_POST['register'])) { $username = mysql_real_escape_string($_SESSION['Username']); // get users username from session $forename = mysqL_real_escape_string($_SESSION['Forename']; //gets already stored forename $newforename = mysql_real_escape_string($_POST['newforename']);//post for new forename $registerquery = mysql_query("UPDATE users SET Forename='$newforename' WHERE Username = '$username'"); // check if the query has return an error if(!$registerquery) { // display the error die('Problem with changing the forename: ' . mysql_error()); } else { // check the query did change anything if(mysql_affected_rows()) { echo 'Forename has been updated!'; $_SESSION['Forename'] = $newforename; // update forename in the session } else { echo 'Forename has not been updated'; } } } ?> <form method="post" action="index.php" name="registerform" id="registerform"> <fieldset> <label for="newforename">Forename:</label><input type="text" name="newforename" id="newforename" /><br /> <input type="submit" name="register" id="register" value="Register" /> </fieldset> </form>
-
Whats the best way to handle URL variables
Ch0cu3r replied to CrimpJiggler's topic in PHP Coding Help
All you need is three url vars id - the page, compound or plant id pagetype - type of product:- page, component or plant action - the action to take, view (show/display), edit, delete, add a page, component or plant To decide which pagetype to display you'd have $id = isset($_GET['id']) ? $_GET['id'] : ''; // the page, compound or plant id $pageType = isset($_GET['type']) ? $_GET['type'] : 'page'; // set page as default pageType $pageAction = isset($_GET['action']) ? $_GET['action'] : 'view'; // set view as default page action $pageTypes = array('page', 'compound', 'plant'); // list available page types $pageActions = array('view', 'edit', 'delete', 'add'); // list possible actions // decide what type of page to view if(in_array($pageType, $pageTypes)) { include $pageType . '.php'; // include the file for pageType } else // display invalid page type error message Then you'd set-up three php files for the pageTypes which are, page.php, compound.php and plant.php In all three you'd have code like this to decide what action to perform if(in_array($pageAction, $pageActions)) { switch($pageAction) { case 'add': // add $pageType break; case 'edit': // edit $pageType break; case 'delete': // delete $pageType break; case 'view': default: // view $pageType } } } else // display invalid action error message -
When you say the session has died what do you mean by this? What is you method for checking the state of the session? Also it is more efficient to compare the users username/password in the mysql query, rather than getting all the results and comparing the username/password with PHP. $username = mysql_real_escape_string($_POST['username']); // sanitize the username before using it in queries $password = $_POST['password']; // should really be encrypting the users password (such as md5, sha1 etc) //check if logged in // only get records where the username and password match $result = mysql_query("SELECT * FROM admin WHERE username='$username' AND password='$password'"); if (!$result) { die("Database query failed: " . mysql_error()); } // check the query returned any results elseif(mysql_num_rows($result)) { // get the result $row = mysql_fetch_assoc($result); // save users data to session here $_SESSION['username'] = $row['username']; $_SESSION['rank'] = $row['rank']; $log = true; }
-
INSERT adds a new record not update a record. You want to use an UPDATE query $registerquery = mysql_query("UPDATE users SET Forename='$newforename' WHERE Username = '$username'"); //finds row for the user and updates the forename column with new record
-
Post line 29
-
Try if(isset($_SESSION["9jsschoo_php_app"])) define('CHATUSER', $_SESSION["9jsschoo_php_app"]->user->username);
-
I guess the question is you want to set the CHATUSER constant to the user's username? If thats the case. Looking at your code when the user logs in successfully you are saving the users data stored in the database into the $_SESSION["9jsschoo_php_app"] variable. Try using if(isset($_SESSION["9jsschoo_php_app"])) define('CHATUSER', $_SESSION["9jsschoo_php_app"]['username']); if that doesn't work then what is the output of printf('<pre>%s</pre>', print_r($_SESSION["9jsschoo_php_app"], 1));
-
If you are new to linux don't install any distro along side Windows. Just install Virtualbox and try out the different distros in a VM (installing guest additions is recommended).
-
Also try using full php tags <?php instead of <?
-
No objnoob is right. The session_start() function cannot be called after any type of output. This is because this functions sets multiple HTTP headers for the session to work. All you need to do is start the session on line one of your script, so it is called before output.
-
That code looks ok to me. What is the output of printf('<pre>%s</pre>', print_r($_POST, true));
-
This rule here RewriteRule ^([0-9]+)-([a-z0-9_-]+)/?$ viewnote.html?id=$1&title=$2 Will match this url mysite.com/10000-armenia-p1-10-rubles-from-1919 ^ +-- first dash ([0-9]+) matches the numbers before the first dash and passes it as the product id ($1) ([a-z0-9_-]+)/? matches anything after the first dash and passes it as the product title ($2) The rewrite rule will not match this url mysite.com/armenia-p1-10-rubles-from-1919
-
www.com/index.php?page=about to www.com/about
Ch0cu3r replied to markveidemanis's topic in Apache HTTP Server
You will need to recode your links to the new url format, eg <a href="http://site.com/about">About Us</a> Then you can apply the following in an .htaccess RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?page=$1 -
No move the echo's so they after are setting the headers