cainfool Posted January 25, 2009 Share Posted January 25, 2009 Hi, I know i'm probably in the wrong forum but I didn't see a "php help". I've seen websites have for eg. my-ultracooldomain.com/index.php?page=coolio I'm not completely sure how they do that, but I know it has PHP involved, and its all in one file. If somebody could give me a example code, it would be fantastic - I'm only new to the forum, and PHP. Quote Link to comment https://forums.phpfreaks.com/topic/142400-php-variables/ Share on other sites More sharing options...
uniflare Posted January 26, 2009 Share Posted January 26, 2009 I would reccommend reading some "Basic PHP Tutorials" (google it), they should get you started. For your specific question though; Every server has the script, the php file that gets called from the URL (Browser); eg: http://www.somenet.com/index.php You can pass arguments to these files by adding an "Argument String", eg; ?argument=value You can pass multiple arguments by concatenating each one with a & (ampersand), eg; ?argument1=value1&argument2=value2&argument... You can also pass arguments to the file via a form - via HTML input elements, the "name" field of the input element will the the "Argument Name", and the value will be whatver the value is on the form. This is how forms work. So, if your script were to receive a request like this: http://www.somenet.com/index.php?therequestname=therequestvalue You can access the "Arguments" that have been passed to the script/server via php's built in globals. For Arguments passed via the URL use the $_GET array, eg; <?php echo($_GET['therequestname']); // Outputs: // therequestvalue ?> For Form Data you would use the $_POST array: <?php echo($_POST['therequestname']); // Outputs: // therequestvalue ?> ... By default, most browsers (if not all) submit a form via the URL - this is bad practice since if your submitting large amounts of information (name/address/email/description/location/etc etc), your url length will most likely break the URL Length Limit. So make sure in your <form> tag you set method="post" ie: <form method="post"> Hope this clears things up for you; Quote Link to comment https://forums.phpfreaks.com/topic/142400-php-variables/#findComment-746131 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.