Jump to content

Age verification script


sparkiem2

Recommended Posts

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.

Link to comment
Share on other sites

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. ;)

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

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!";
}

?>

 

Link to comment
Share on other sites

  • 2 months later...
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...  :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.