HuggieBear
Members-
Posts
1,899 -
Joined
-
Last visited
Everything posted by HuggieBear
-
how to get the posted value after reloading that page
HuggieBear replied to thulasi's topic in PHP Coding Help
Like I mentioned in the previous thread. Post what code you have and we can take a look at it. Regards Huggie -
how to get the posted value after reloading that page
HuggieBear replied to thulasi's topic in PHP Coding Help
Let me guess, this is for an exam? See this thread: http://www.phpfreaks.com/forums/index.php/topic,114520.msg465960.html#msg465960 Huggie -
I don't know why Orio suggested the change... Just use the sql function [color=green]now()[/color]; Regards Huggie
-
Why won't the values change? (should be easy...)
HuggieBear replied to kaze's topic in PHP Coding Help
Where you have [code=php:0]$c = $c +1;[/code] you can use an [url=http://uk.php.net/manual/en/language.operators.increment.php]increment operator[/url] to do away with this line completely, so your code will look like this: [code]<?php function thisisit($x, $c){ global $arra; $arra[$c++] = $x; return $c; } $function_result = thisisit($x, $c); ?>[/code] -
Try using empty() with tmp_name... [code]<?php if (!empty($_FILES['new_pdf']['tmp_name'])){ $new_pdf = $_FILES['new_pdf']['tmp_name']; } else { $new_pdf = $_POST['old_pdf']; } ?>[/code] Regards Huggie
-
Yes, I believe that it's implying that forename is set to NOT NULL, meaning it can't be left blank. If it has a default value, then you can get away without including it in your INSERT code, as the default will be used, but if it doesn't you'll have to provide something. Incidentally, why are you not wanting to put something into a column that is required? Regards Huggie
-
You need to change this... [code=php:0]if ($file_upload='true')[/code] to this... [code=php:0]if ($file_upload == "true")[/code] Notice the double equals sign! Regards Huggie
-
Thanks Thorpe, I did read the manual, and I saw the bit about default variables, but I guess I didn't take it in. Think I'll head to bed and pick this up in the morning. Regards Huggie
-
I have the following function which prints a form, now as you can see, it accepts an argument, the argument is the location that the form submits to. Now if I call the function with an argument it works fine, however, if I leave it blank I get an error. The code is: [code]<?php function drawForm($location){ $location = isset($location) ? $location : $_SERVER['PHP_SELF']; $out = <<<HTML <form name="login" id="login" method="post" action="$location"> <!-- My form code here --> </form> HTML; return $out; } ?>[/code] The error is: [quote]Warning: Missing argument 1 for drawForm(), called in ....[/quote] I know the error is coming and I know why, but is there a way to get around it. I can suppress the error by calling [code=php:0]echo @drawForm();[/code] but I'm not keen in that really. How can I make an argument optional? Regards Huggie
-
Just use [code=php:0]$_SESSION['var'] = $var;[/code] after you've assigned the array to $var. Regards Huggie
-
This can't be done in PHP. Try looking into JavaScript for this. Regards Huggie
-
Repeat Region in a two column table
HuggieBear replied to alexisfromboston's topic in PHP Coding Help
Alexis, I think there's a post in the FAQ's somewhere about displaying data in columns. I've done it a few times recently on my pages and helped a few people out on here. Displaying data horizontally is easier than vertically, but neither are too much of a pain. Try searching the forums here, I'm on my way out now, but if you haven't had any joy when I get back into the office tomorrow I'll take a look at it for you. Regards Huggie -
I think you're unlikely to find something 'off the shelf' like that. Have a search on somewhere like [url=http://www.hotscripts.com]Hotscripts[/url]. This forum is mainly for those who've tried and aren't getting anywhere, or just need a few bits of help here and there, If you want someone to write something for you, then post maybe in the [url=http://www.phpfreaks.com/forums/index.php/board,8.0.html]PHP Freelancing[/url] forum. I don't think you're likely to get it for free, but who knows. If you're prepared to pay even a little for something, say between $20 and $30, that's enough to get some people interested. If after this you still have no joy then feel free to PM me and I'll take a look at it for you. Regards Huggie [size=8pt][color=red][b]Edit:[/b][/color] I posted the wrong link to the Freelance forum before, but I've updated it now.[/size]
-
OK, I thought you had the code that did that and just wanted the payment integrating. So do you not have any code? Huggie
-
It looks as though you want to use PayPal's IPN service. It stands for "Instant Payment Notification". If you go to PayPal and search their site you'll get a few more details. Regards Huggie
-
Yes, you get the value via the $_POST variable but then assign it to a session variable by using something like [code=php:0]$_SESSION['username'] = $_POST['username'];[/code] Then you can use [code=php:0]$_SESSION['username'][/code] on any page where you specify [code=php:0]session_start();[/code] at the top. So [b]register.php[/b] looks like this: [code]<?php // Start Session session_start(); // Print form echo <<<HTML <form name="register" method="post" action="confirm.php"> <input type="text" name="firstname" value="{$_SESSION['firstname']}"> Firstname<br> <input type="text" name="lastname" value="{$_SESSION['lastname']}"> Lastname<br> <input type="text" name="email" value="{$_SESSION['email']}"> Email Address<br> <input type="text" name="username" value="{$_SESSION['username']}"> Username<br> <input type="password" name="password"> Password<br> <input type="submit" name="submit" value="Submit"> </form> HTML; ?>[/code] and [b]confirm.php[/b] looks like this: [code]<?php // Start Session session_start(); // Make sure they've posted the form if (!isset($_POST)){ header("Location: register.php"); } // Put the values into session variables foreach ($_POST as $name => $value){ $_SESSION[$name] = $value; } // Ask the user to confirm echo "Is the following info correct...<br>\n"; // echo all your $_POST variables here echo "Firstname: {$_POST['firstname']}<br>\n"; // Ask the user to go back if incorrect echo "If info is incorrect then <a href=\"register.php\">go back</a><br>\n"; ?>[/code] Regards Huggie
-
Both mine and Orio's examples use session variables as specified in your first post. Regards Huggie
-
OK, here's some code, it's stripped down to basics and just has comments where you can fill bits in yourself, but a few basics, my login form is called login.php, my secure content page is called menu.php. [b]menu.php[/b] [code]<?php // Start Session session_start(); // Check if my user details have been stored in session vars yet if (!isset($_SESSION['username'])){ header("Location: login.php"); } else { echo "You are logged in {$_SESSION['username']}, welcome to the main menu...\n"; } ?>[/code] You could even put the first few lines into a header file and just use an include to include it on each page. [b]login.php[/b] [code]<?php // Start Session session_start(); // Connect to db include('connect.php'); // Under what pretence are we here, redirected, or just submitted the login form if (!isset($_POST['submit'])){ // the form hasn't been submitted so we just landed here or were directed here, so lets get details if (isset($_SESSION['username'])){ // We must have returned here having already logged in once this session header("Location: menu.php"); } else if (isset($_COOKIE['authenticated']) && !isset($_SESSION['username'])){ // If we have the remember me cookie, but it's the first time we've logged in this session $sql = "SELECT * FROM users WHERE id = '{$_COOKIE['authenticated']}'"; $result = mysql_query($sql); $u = mysql_fetch_array($result, MYSQL_ASSOC); $_SESSION['username'] = $u['username']; $_SESSION['realname'] = $u['name']; $_SESSION['email'] = $u['email_address']; header("Location: menu.php"); } else { // We don't have a cookie set at all, we need to login // -- put your form code here -- } } else { // The form's been submitted, so process it // Get our username and password from the form using $_POST variables // -- put your processing code here -- // Check them against the database for successful login $sql = "SELECT * FROM users WHERE username = '{$_POST['username']}' AND password = '{$_POST['password']}'"; $result = mysql_query($sql); // Did the user authenticate OK? if (mysql_num_rows($result) == 1){ // Authenticated OK $u = mysql_fetch_array($result); $_SESSION['username'] = $u['username']; $_SESSION['realname'] = $u['name']; $_SESSION['email'] = $u['email_address']; // Now comes the important cookie part // if 'remember_me' is set, cookie expires in 30 days, if it's not, then expires at end of session $expire = isset($_POST['remember_me']) ? time()+60*60*24*30 : null; // Set the cookie using the above $expire variable setcookie("authenticated", $u['id'], $expire, "/", "yourdomain.co.uk"); header("Location: menu.php"); } else { // Not authenticated // Print your form code // -- put your form code here -- } } ?>[/code] Now you'll see some repeated code here that could be put into functions, such as echoing the form code and retrieving details from the database, but I wanted to give you the gist of the code, not the intricacies of it. Regards Huggie
-
Change the form to this: [code]<form action="process7qs.php" method="post"> Please type your name<p> <input name="data1" size="40" maxlength="80" value="<?php echo $HTTP_SESSION_VARS['data1']; ?>"> <input type="submit" value="Send">...[/code] Don't forget to use session_start() at the top of your pages before outputting anything else. Regards Huggie
-
I believe it is possible. Try googling for "multipart mime" and see what you come up with. As an alternative, you could try sending an email in html format and embedding a link to a remotely hosted SWF file, this would reduce bandwidth on the positive side, but would mean when people are offline they wouldn't be able to view it. Having said that, in the day and age of broadband, those who download mail for viewing offline are decreasing in size :) Regards Huggie
-
You can also use [url=http://uk.php.net/manual/en/function.unset.php]unset()[/url] Regards Huggie
-
Although a slightly different approach to what you have there, I'd create maybe an event calendar, like the one in the tutorial that Obs wrote recently [url=http://www.phpfreaks.com/tutorials/144/0.php]here @ PHPFreaks[/url] as my starting point (You'll need a few code tweaks as the code doesn't work out of the box, there's a few typos in there). Then add events for each of your classes, finally tie in a users table to allow for entry of attendees. Using the event calendar tutorial with a little bit of code tweaking and style sheets, I came up with the following: http://dizzie.co.uk/calendar (Yellow shows the current day, Purple shows days with events on). Then I added a few additional tables, and voila! Regards Huggie
-
dealing with the ampersand '&' character in php/mysql
HuggieBear replied to mark_nsx's topic in PHP Coding Help
Yes, that's exactly what's causing the problem. Regards Huggie -
dealing with the ampersand '&' character in php/mysql
HuggieBear replied to mark_nsx's topic in PHP Coding Help
Use [url=http://uk.php.net/manual/en/function.htmlentities.php]htmlentities()[/url] on the text you want to put into the database, this will convert the & to & Regards Huggie