Quote:
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.
Printable View
Quote:
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.
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);
Pretty much yes. Consider using sessions.Quote:
do i have to "rePOST" the variables use time i go from document to document?
i think im going to try and use cookies for this
Quote:
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.
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
}
Quote:
Originally Posted by MisterSako
No.
For the intranet I maintain at work, I have multiple files with 1000+ each. Php is more then capable.
i must have some kind of oddly placed } or something
You should split your code a bit to make it more organized.
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 ♠ܥ
Quote:
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!";
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:Quote:
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');
It was a typo. I make mistakes.Quote:
Originally Posted by laserlight
Every once in a while. The //'s are what i was going for.