Originally Posted by MisterSako
Theres no NEED to send post variables across pages. Instead, you save the post variables in your session data, and check that data in the next page.
Originally Posted by MisterSako
Theres no NEED to send post variables across pages. Instead, you save the post variables in your session data, and check that data in the next page.
c++->visualc++->directx->opengl->c++;
(it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)
i don't get this,
i POST to my process file so i can get the variables with $username = $_POST['username']; type of thing but i don't get why i cant just use that same thing again once it directs the user back to the registration page to have the textfields show what they last had.
do i have to "rePOST" the variables use time i go from document to document?
ive tried sending the user back to the register page using
META HTTP-EQUIV=Refresh CONTENT="2; URL="
as well as header: location
Another option is to pass it in query string.
Cookies is another, if it's appropriate at all.Code:$redirect_to = 'http://mysite.com/register.php?username=' + urlencode($username);
source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense
Pretty much yes. Consider using sessions.do i have to "rePOST" the variables use time i go from document to document?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
i think im going to try and use cookies for this
Originally Posted by MisterSako
It seems clear you are either really unclear on what sessions are all together, or you just don't get it.
Your POST variables are ways for your users to REQUEST something of you. In order to do that, they are sending extra data to your page. Believe it or not, there is an Overhead here that while not remarkble will add up in worse case scenarios. Once a user has sent data to you once, theres absolutely no reason to continue to cary it around via request methods. Instead, you save the data in SESSIONS. Sessions stay across multiple pages and even multiple visits.
To use sessions, it's really this simple:
Afterwards, on any other page in your site:PHP Code:
<?php
session_start();
// if the user has sent us a variable via GET or POST, save it
if(isset($_REQUEST['a_variable_name']))
$_SESSION['a_variable_name'] = $_REQUEST['a_variable_name'];
?>
PHP Code:
<?php
session_start();
// for some reason i want to display the form again
// with the data they originaly sent me
echo "<input type='text' name='a_variable_name' value='{$_SESSION['a_variable_name']}'/>";
?>
It's really very simple.
c++->visualc++->directx->opengl->c++;
(it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)
i understand the purpose of sessions ive just gone crazy pulling my hair out to try and get it to work.
on a side note does php have a limit no how long a if statement can be. i got into a weird situation where its like
and the else part only has partially the stuff it should have, wihtint that 500 lines theres ?> and <?php and ?> and <?php alot of times so maybe they could be messing it up.PHP Code:
if (this){
//10 lines of code
} else {
like 500 lines of code
}
Originally Posted by MisterSako
No.
For the intranet I maintain at work, I have multiple files with 1000+ each. Php is more then capable.
c++->visualc++->directx->opengl->c++;
(it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)
i must have some kind of oddly placed } or something
You should split your code a bit to make it more organized.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
i try to, but there is also a pointy if i have too many different php files ill eventualy be overwhelmed with a plethora of php files that are all used for one thing
is there a alphanumeric test code that actually works?
i want it to tell me if there are any characters in a stringbesides a-z A-z or 0-9
i tried
if (ereg('[^A-Za-z0-9]', $string))
and i tried
if (ctype_alnum($string))
both will not work, theyre always wanting to say everything i input is alphanumeric even if its like ♠ܥ
Originally Posted by MisterSako
http://www.tote-taste.de/X-Project/regex/
http://www.phpguru.org/downloads/PCR...at%20Sheet.pdf
use http://www.quanetic.com/regex.php to test. I use it all the time. It does have a bug where you have to use double '\'s to work on special chars. so \d would be \\d
A '^' outside means match the beginning of the string.
what you want is /[a-zA-Z0-9]/
also, i'd use preg_match:
PHP Code:
if(preg_match("/[a-zA-Z0-9]/", $str))
echo "bad input!";
Last edited by Jeremy G; 03-07-2006 at 07:18 PM.
c++->visualc++->directx->opengl->c++;
(it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)
Actually, you might as well use ctype_alnum(), which is like C's isalnum() from <stdio.h>
Should be faster (and somewhat simpler) than using regex, but then is literally limited to testing that each character of the whole string is indeed in the range of A-Za-z0-9
Unfortunately, Jeremy G, your use of preg_match() is wrong. Your pattern matches any alphanumeric character, spewing out a "bad input!" message if one is found. Correct is:also, i'd use preg_match:
EDIT:PHP Code:
if (preg_match('/[^A-Za-z0-9]/', $string)) {
echo "bad input!";
}
I see that you have tried ctype_alnum() and it didnt work. Most probably you have to do a:
before you use ctype_alnum()PHP Code:
setlocale(LC_CTYPE, 'C');
Last edited by laserlight; 03-07-2006 at 10:10 PM.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
It was a typo. I make mistakes.Originally Posted by laserlight
Every once in a while. The //'s are what i was going for.
c++->visualc++->directx->opengl->c++;
(it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)