sparkiem2 Posted April 7, 2018 Share Posted April 7, 2018 I need an age verification php script. I am not real good with code. I would like to find one with step by step instructions. I found one here in a real old post that I would like to use but just cannot get it to work. Here is page it is on. https://forums.phpfreaks.com/topic/190739-age-verification-script Any help would be greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/307066-age-verification-script/ Share on other sites More sharing options...
Barand Posted April 7, 2018 Share Posted April 7, 2018 Have you tried posting in the forums over at psionguild.org? They are telepathic over there, so there will be no need for you to post your code for them to know exactly what you are doing and how you are implementing the code. Unfortunately we are less gifted in these forums. Quote Link to comment https://forums.phpfreaks.com/topic/307066-age-verification-script/#findComment-1557683 Share on other sites More sharing options...
gizmola Posted April 7, 2018 Share Posted April 7, 2018 I need an age verification php script. I am not real good with code. I would like to find one with step by step instructions. I found one here in a real old post that I would like to use but just cannot get it to work. Here is page it is on. https://forums.phpfreaks.com/topic/190739-age-verification-script Any help would be greatly appreciated You have to be more specific than "cannot get it to work." We need to see relevant code snippets. We need to know what errors, or behavior you are finding. We need to know something about your environment (hosting, web server, configuration details) We need to know about any errors or debugging efforts you have made. The people who answer the majority of questions on this forum are all exceedingly experienced and knowledgable and bend over backwards to help people, but to Barand's point, we aren't Psychics. I will also tell you that the first thing you need to do to solve problems like this, is get to a point where you have at minimum some debugging techniques in your toolbox so you can start to figure out what is going on. echo, var_dump and print_r are a start. If something "doesn't work" sometimes you need to start tracing the code and trying to figure out where things divert from your expectations. Also with all due respect, this is a forum for programmers to help other programmers. We don't always chase off people like yourself, who admittedly just want to solve a problem, without learning to understand the code adequately themselves, but there isn't much of a win for the overall community for someone to hand hold anyone with basic PHP. If you are going to flounder, you have to eventually ask yourself if it wouldn't be better to PayPal someone for an hour or 2 of their time rather than spend lots of time floundering in an area you don't understand, nor have a huge personal incentive to learn yourself. The entire idea that web development is akin to following a recipe for cooking a chicken casserole is highly overrated. The modern web is complicated, and full of foundation elements that are technical and require understanding to master. A typical developer is capable of debugging many disparate elements when solving problems. For all we know your code could be perfectly viable, but due to some hosting configuration, simply isn't going to work for you without adjustments to your hosting environment. Either way, if you intend to pursue help here, you need to improve your question asking game dramatically. 1 Quote Link to comment https://forums.phpfreaks.com/topic/307066-age-verification-script/#findComment-1557684 Share on other sites More sharing options...
happypete Posted April 27, 2019 Share Posted April 27, 2019 Try this. Create an index.php, ageCheck.php & verified.php page and use the code below. Navigate to the verified.php page in the browser first (to check its working) you should automatically be redirected to the index.php page. Now if you select "i'm 21" then you will be redirected to the verified page. index.php <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> </head> <body> <form method="POST" action="ageCheck.php"> <input type="submit" name="valid_age" value="I'm 21" /> <input type="submit" name="invalid_age" value="Nope. I sit at the kid's table" /> </form> </body> </html> When they select either of the button the details will be sent to the ageCheck.php page: ageCheck.php <?php //Start session session_start(); /* * First, we want to make sure they came to this ageCheck.php via a form. * Then we can check to see if $_POST['valid_age'] is set, since it will only * be set if they pressed the "I'm 21" button. */ if(isset($_POST)){ if(isset($_POST['valid_age'])){ /* * Since they got here, it means they are of the right age. * Now we set the session value. */ $_SESSION['age_verified'] = true; header("Location: verified.php"); exit; }else{ /* * To young! Just re-direct them to Google. */ header("Location: http://www.google.com"); exit; } }else{ die("Trying to sneak in are we?"); } ?> This page will send them to google.com if they have selected "Nope. I sit at the kid's table", or send them to verified.php if they selected "I'm 21" verified.php <?php //Start the session session_start(); /* * If they haven't passed the age test * then the age_verified session will not * be set, since it is only set if they * say they are 21 years of age. */ if(!isset($_SESSION['age_verified'])){ header("Location: index.php"); exit; } else { $verified = "your age has been verified!"; } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> </head> <body> <?php echo $verified; ?> </body> </html> On the verified page it will again check if they are verified (and send them to index.php if not) of will echo "your age has been verified!" Any other page that you want them to visit and check they have been verified their age, add this code at the top. If they are not verified it will send then back to the index.php page <?php //Start the session session_start(); /* * If they haven't passed the age test * then the age_verified session will not * be set, since it is only set if they * say they are 21 years of age. */ if(!isset($_SESSION['age_verified'])){ header("Location: index.php"); exit; } else { $verified = "your age has been verified!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/307066-age-verification-script/#findComment-1566347 Share on other sites More sharing options...
quasiman Posted July 9, 2019 Share Posted July 9, 2019 On 4/27/2019 at 6:20 AM, happypete said: Try this. Create an index.php, ageCheck.php & verified.php page and use the code below. That's a great effort, but you're assuming a lot by posting this much information. Hopefully it's helpful... Quote Link to comment https://forums.phpfreaks.com/topic/307066-age-verification-script/#findComment-1568260 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.