Show DevBest Useful Code?

Status
Not open for further replies.

NSA

sudo apt-get thefuckout.tar.gz
Dec 9, 2011
715
86
Hello,

Got bored and started making a random page which isn't really useful.
I guess it's useful for the new people at coding as there's a mix in here.
Just play about with it and stuff. idk.

NOTE: Change the form action to whatever you save it as, it must be .PHP!

PHP:
<!DOCTYPE html>
<html>
<head>
    <title>PHP Testing</title>
</head>
<body>
    <form action="php-new.php" method="post"
 
onsubmit="return checkform(this);">
        <label for="username">Username:
 
</label><br /><input type="text" name="username"><br
 
/>
        <label for="password">Password:
 
</label><br /><input type="password"
 
name="password"><br />
        <label for="age">Age: </label><br
 
/><input type="text" name="age"><br />
        <label for="country">Country:
 
</label><br /><input type="text" name="country"><br
 
/>
        <input style="visibility:hidden;"
 
checked="checked" type="radio" name="sex"
 
value="yes">
        <input type="submit" value="Submit">
    </form>
<?php
    error_reporting(0);
 
    $username = $_POST['username'];
    $password = $_POST['password'];
    $age = $_POST['age'];
    $country = $_POST['country'];
    $shown = $_POST['sex'];
    if($shown == "yes"){
        echo "<h1>Results!</h1> <br />";
    echo "<p>";
    echo "Username: " . $username;
    echo "<br />";
    echo "Password: " . $password;
    echo "<br />";
    echo "Age: " . $age;
    echo "<br />";
    echo "Country: " . $country;
    echo "</p>";
    }
    else{
 
    }
?>
<div id="editMe">
<h1 id="hello">Hello</h1>
</div>
<script type="text/javascript">
    function startMe(){
        document.getElementById
 
('hello').innerHTML = "Heljjjjlo!";
        }
    function checkform ( form )
{
 
  // ** START **
  if (form.username.value == "") {
    alert( "Please enter you name!" );
    form.username.focus();
    return false ;
  }
  if (form.password.value == "") {
    alert( "Please enter you password!" );
    form.password.focus();
    return false ;
  }
  if (form.age.value == "") {
    alert( "Please enter you age!" );
    form.age.focus();
    return false ;
  }
  if (form.country.value == "") {
    alert( "Please enter you country!" );
    form.country.focus();
    return false ;
  }
  // ** END **
  return true ;
}
</script>
<input type="button" value="Click me!"
 
onClick="startMe();">
</body>
</html>
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,638
2,393
Thread closed until you comment on what this code actually does.

You say you wrote this to let new people to coding look at it, but it just seems like an absolute jumble of code, comment it and then PM me when you have done so and I shall unlock the thread.
 
Status
Not open for further replies.

Users who are viewing this thread

Top