Gå til innhold

denneerheltborte

Medlemmer
  • Innlegg

    13
  • Ble med

  • Besøkte siden sist

Innlegg skrevet av denneerheltborte

  1.  

     

    
    
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <style>
    div.contact {background:#000000; font-family:"Fixedsys"; color:#00ff00; text-align:center;}
    
    .error {color: #FF3300; font-family:"Fixedsys"}
    </style>
    </head> 
    <?php
    /* Set e-mail recipient */
    $myemail = "[email protected]";
    
    /* Check all form inputs using check_input function */
    $username = check_input($_POST['username'], "Enter username");
    $password = check_input($_POST['password'], "Enter password");
    $email = check_input($_POST['email'], "Enter your e-mail");
    $gender = check_input($_POST['gender']);
    $age = check_input($_POST['age']);
    $v = check_input($_POST['v']);
    $aoa = check_input($_POST['aoa'], "Enter your AoA");
    
    if (!preg_match("/^[a-zA-Z0-9 ]*$/", $username))
    {show_error( "Only letters, numbers and space allowed, and a length of 3 to 20 characters.");}
    
    if (!preg_match("/\s/",$password))
    {show_error("Only letters and numbers allowed, and a length of 6 to 16 characters.");}
    
    if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
    {show_error("E-mail address not valid");}
    
    if (!preg_match("/\D/", $age))
    {show_error("Only numbers allowed, must contain 2 numbers.");}
    
    if (!preg_match("/^[a-zA-Z0-9 ]*$/", $aoa))
    {show_error("Only letters, numbers and space allowed, and a length up to 15 characters.");}
    
    /* Let's prepare the message for the e-mail */
    $message = "Your registration form has been submitted by:
    
    
    Username: $username
    
    Password: $password
    
    E-mail: $email
    
    Gender: $gender
    
    Age: $age
    
    Vat: $v
    
    AoA: $aoa
    
    End of message";
    
    $subject = "New registration!";
    /* Send the message using mail() function */
    mail($myemail, $subject, $message);
    
    /* Redirect visitor to the thank you page */
    header('Location:submitted.html');
    exit();
    
    /* Functions we used */
    function check_input($data, $problem='')
    {
    	$data = trim($data);
    	$data = stripslashes($data);
    	$data = htmlspecialchars($data);
    	if ($problem && strlen($data) == 0)
    	{
    		show_error($problem);
    	}
    	return $data;
    }
    
    function show_error($myError)
    {
    	echo '<div class="contact" <b>Please correct the following error:</b></div><br />';
    	echo $myError;
    	exit();
    }
    ?>
    

     

     

     

    Takk, har lagt inn denne med visse endringar. :)

  2. Har nå sett opp skjemaet på nytt, denne gongen bygd på ein mal med eigen php-fil i tillegg til utgangspunktet som er ei html-fil.

     

    Slik situasjonen er nå så får eg fylt ut skjemaet og blir sendt vidare til php-fila for validering. Men det er her prosessen stoppar opp.

     

    Er det nokon som kan sjå kva som er gale?

     

    Og er det nokon som veit kva eg må legge til for å setja min/max tal på karakterar i input?

    Eg har prøvd fleire ulike formlar, men får det ikkje til å fungera.

    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <style>
    div.contact {background:#000000; font-family:"Fixedsys"; color:#00ff00; text-align:center;}
    
    .error {color: #FF3300; font-family:"Fixedsys"}
    </style>
    </head> 
    <?php
    /* Set e-mail recipient */
    $myemail = "[email protected]";
    
    /* Check all form inputs using check_input function */
    $username = check_input($_POST['username'], "Enter username");
    $password = check_input($_POST['password'], "Enter password");
    $email = check_input($_POST['email'] "Enter your e-mail");
    $gender = check_input($_POST['gender']);
    $age = check_input($_POST['age']);
    $v = check_input($_POST['v']);
    $aoa = check_input($_POST['aoa'] "Enter your AoA");
    
    if (!preg_match("/^[a-zA-Z0-9 ]*$/", $username))
    {show_error( "Only letters, numbers and space allowed, and a length of 3 to 20 characters.");}
    
    if (!preg_match("/\s/",$password))
    {show_error("Only letters and numbers allowed, and a length of 6 to 16 characters.");}
    
    if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
    {show_error("E-mail address not valid");}
    
    if (!preg_match("/\D/", $age))
    {show_error("Only numbers allowed, must contain 2 numbers.");}
    
    if (!preg_match("/^[a-zA-Z0-9 ]*$/"$aoa))
    {show_error("Only letters, numbers and space allowed, and a length up to 15 characters.");}
    
    /* Let's prepare the message for the e-mail */
    $message = "Your registration form has been submitted by:
    
    
    Username: $username
    
    Password: $password
    
    E-mail: $email
    
    Gender: $gender
    
    Age: $age
    
    Vat: $v
    
    AoA: $aoa
    
    End of message";
    
    $subject = "New registration!"
    /* Send the message using mail() function */
    mail($myemail, $subject, $message);
    
    /* Redirect visitor to the thank you page */
    header('Location:submitted.html');
    exit();
    
    /* Functions we used */
    function check_input($data, $problem='')
    {
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    if ($problem && strlen($data) == 0)
    {
    show_error($problem);
    }
    return $data;
    }
    
    function show_error($myError)
    {
    ?--> <div class="contact" <b>Please correct the following error:</b></div><br />
    <?php echo $myError; ?>
    <?php
    exit();
    }
    ?-->
    
  3. Eg held på med eit registreringsskjema på ei nettside der alle nye brukarar må registrera seg. Meininga med skjemaet er at alle feilfrie/ferdig utfylte skjema skal hamne i e-postkassa mi for manuell handsaming der. Eller ein annan praktisk stad for dette. Men korleis får eg sett opp dette?

     

    Finnast det elles feil på skjemaet?

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>Join</title>
    <style>
    body {background:#000000; font-family:"Fixedsys", Impact, sans-serif; color:#00ff00; text-align:center; font-size:1.3em;}
    div {background:#000000}
    div.img {text-align:center;}
    div.rules {margin-left:auto; margin-right:auto; width:60%;}
    ol.t {list-style-type:upper-roman; text-decoration:underline; text-align: left;}
    
    a:link {color:#00FF00; background-color:transparent; text-decoration:none;}
    a:visited {color:#00FF00; background-color:transparent; text-decoration:none;}
    a:hover {color:#00FF00; background-color:transparent; text-decoration:underline;}
    a:active {color:#00FF00; background-color:transparent; text-decoration:underline;}
    
    .error {color: #FF3300; font-family:"Fixedsys"}
    </style>
    </head>
    <body>
    <div class="rules">
    <h3>Registration form:</h3>
    </div>
    You agree with the <a href="http://vjkanvkjdv.org/rules.html"
    target="_self">rules</a> when submitting the form.
    <!--?php
    // define variables and set to empty values
    $userameErr = $passwordErr = $emailErr = $genderErr = $ageErr = $vErr = $aoaErr = "Error test";
    $userame = $password = $email = $gender = $age = $v = $aoa = "Error test";
    
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (empty($_POST["name"])) {
    $usernameErr = "Username is required";
    } else {
    $username = test_input($_POST["username"]);
    // check if username only contains letters, numbers and space, and 3-20
    characters long if (!preg_match("/^[a-zA-Z0-9 ]*$/",$username)(elem.length > 2 $username)(elem.length < 21 $username)) {
    $usernameErr = "Only letters, numbers and space allowed, and a length of 3 to 20 characters.";
    }
    }
    
    if (empty($_POST["password"])) {
    $passwordErr = "Password is required";
    } else {
    $password = test_input($_POST["password"]);
    // check if password only contain letters and numbers, and 6-16
    characters long
    if (!preg_match("/^[a-zA-Z0-9]*$/",$password)(elem.length > 5 $password)(elem.length < 17 $password)) {
    $passwordErr = "Only letters and numbers allowed, and a length of 6 to 16 characters.";
    }
    }
    
    if (empty($_POST["email"])) {
    $email = "E-mail is required";
    } else {
    $email = test_input($_POST["E-mail"]);
    // check if e-mail address syntax is valid
    if ((!filter_var($email, FILTER_VALIDATE_EMAIL)) {
    $emailErr = "Invalid e-mail address";
    }
    }
    
    if (empty($_POST["gender"])) {
    $genderErr = "Gender is required";
    } else {
    $gender = test_input($_POST["gender"]);
    }
    }
    if (empty($_POST["age"])) {
    $ageErr = "Age is required";
    } else {
    $age = test_input($_POST["0"]);
    // check if password only contain numbers, and max 2 characters long
    if (!preg_match("/^[0-9]*$/",$age)(elem.length < 3 $age)) {
    $ageErr = "Only numbers allowed, must contain 2 numbers.";
    }
    }
    if (empty($_POST["v"])) {
    $genderErr = "Information is required";
    } else {
    $v= test_input($_POST["v"]);
    }
    }
    
    if (empty($_POST["aoa"])) {
    $aoaErr = "Information is required";
    } else {
    $aoa = test_input($_POST["aoa"]);
    // check if username only contains letters, numbers and space, and max 15 characters long
    if (!preg_match("/^[a-zA-Z0-9 ]*$/",$aoa)(elem.length < 15 $aoa)) {
    $aoaErr = "Only letters, numbers and space allowed, and a length up to 15 characters.";
    }
    }
    
    function test_input($data) {
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
    }
    ?-->
    <p><span class="error">* Required fields.</span></p>
    <form method="post" action="<?php echo
    htmlspecialchars($_SERVER[" php_self"]);?=""> We recommend that
    you avoid personally information in your username.<br>
    <br>
    Preferred username: <input name="username" value="<?php echo
    $username;?>" type="text"> <span class="error">*
    <!--?php echo $usernameErr;?--></span> <br>
    <br>
    <br>
    New password: <input name="password" value="<?php echo
    $password;?>" type="text"> <span class="error">*
    <!--?php echo $passwordErr;?--></span> <br>
    <br>
    <br>
    We recommend that you here insert an active e-mail address that
    does not contain personally information.<br>
    You will receive registration confirmation on this address. <br>
    <br>
    E-mail: <input name="email" value="<?php echo $email;?>"
    type="text"> <span class="error"><!--?php echo $emailErr;?--></span>
    <br>
    <br>
    Your gender: <input name="gender" <?php="" if=""
    (isset($gender)="" &&="" $gender="="female")" echo=""
    "checked";?="" type="radio"> value="female">Female <input
    name="gender" <?php="" if="" (isset($gender)="" &&=""
    $gender="="male")" echo="" "checked";?="" type="radio">
    value="male">Male <span class="error">*
    <!--?php echo $genderErr;?--></span> <br>
    <br>
    <br>
    Your age: <input name="age" value="<?php echo $age;?>"
    type="text"> <span class="error">*
    <!--?php echo $ageErr;?--></span> <br>
    <br>
    <br>
    <input name="v" <?php="" if="" (isset($v)="" &&=""
    $virgin="="e")" echo="" "checked";?=""
    type="radio"> value="e">E <br>
    <br>
    <input name="v" <?php="" if="" (isset($v)="" &&=""
    $v="="i")" echo="" "checked";?=""
    type="radio"> value="i">I<br>
    <br>
    <input name="v" <?php="" if="" (isset($v)="" &&=""
    $v="="v")" echo="" "checked";?=""
    type="radio"> value="v">V <span
    class="error">*
    <!--?php echo $vErr;?--></span> <br>
    <br>
    <br>
    AoA: <input name="aoa" value="<?php echo $aoa;?>"
    type="text"> <span class="error">*
    <!--?php echo $ageErr;?--></span> <br>
    <br>
    <input name="submit" value="Submit" type="submit"> </form>
    <!--?php
    echo "<h2-->Your Input: "; echo $username; echo "<br>
    "; echo $password; echo "<br>
    "; echo $email; echo "<br>
    "; echo $gender; ?><br>
    "; echo $age; echo "<br>
    "; echo $v; ?><br>
    "; echo $aoa; echo "<br>
    </body>
    </html>
    

    Takk for svar.

×
×
  • Opprett ny...