So, I have been beating around the bush and really havent learned php. ive been looking into other scripts and pre-made code, and I apologize for all those who asked for work for me. Now I am learning php though, and am going to write scripts from scratch and post the tutorials here. I am learning from www.w3schools.org for those who might want to know. Anyways, i will update this thread regularly with new tuts and scripts. They will start out simple
Age check. Great for sites with age requirments or to be inplemented in a registration system.
Here we go:
First create a file for your html code and include the following code:
CODE
<html>
<body>
<form action="checkage.php" method="post">
<input type="radio" name="age" value="18"> I am 18
<input type="radio" name="age" value="17"> I am younger than 18
</form>
</body>
</html>
<body>
<form action="checkage.php" method="post">
<input type="radio" name="age" value="18"> I am 18
<input type="radio" name="age" value="17"> I am younger than 18
</form>
</body>
</html>
Now to break down the code:
*Form action="checkage.php" is requiring the file we will create shortly. This is what will do the actual checking of the age
*the input type="radio" is the type of input it will show. This will be a button, but you can also change it with a simple type box by replacing "radio" with the "text" tag or for a checkbox the "checkbox" tag
*name="age" is what the age will be called. This helps the php code identify what to check
Now create a new file named checkage.php. Heres the code:
CODE
<?php
$age=$_POST['age'];
if ($age >= 18)
{
echo 'Welcome, you may proceed'
}
else
{
echo 'You are not old enough, please leave now'
}
?>
$age=$_POST['age'];
if ($age >= 18)
{
echo 'Welcome, you may proceed'
}
else
{
echo 'You are not old enough, please leave now'
}
?>
Now break down the code:
*$age=$_POST['age'] is getting the age that was inputed from the form in the html form. It is also identifying $age as a variable
* if ($age >= 18) is checking to make sure the user is 18, else it will echo the "you are not old enough, please leave now" message.
And there you have it! I know its simple, but im just learning to do things from scrath.
This code can be used and distributed, but please leave a link back to this thread. This is MY work. If you are having trouble with the code just post here
