Jump to content

PHPTOM

Members
  • Posts

    84
  • Joined

  • Last visited

Posts posted by PHPTOM

  1. You didn't say if you were using PHP 5 or not. But this is a PHP file email validator in it.

    <?php
    if(isset($_POST['submit'])) {
    $to = "test@test.com";
    $subject = "Contact Form";
    $name_field = $_POST['name'];
    $email_field = $_POST['email'];
    $message = $_POST['message'];
    if(!$name_field || !$email_field || !$message){
    echo "You missed a field!";
    	}elseif(!filter_var($email_field, FILTER_VALIDATE_EMAIL)) {
    	echo "Invalid email!";
    }else{
    	foreach($_POST['check']  as  $value)  {
    		$check_msg .= "Checked: $value\n";
    	} 
    	$body  =  "From: $name_field\n E-Mail: $email_field\n Message:\n $message\n $check_msg"; 
    	mail($to, $subject, $body);
    	echo "Thankyou for your message, you will now be returned ";
    }
    }else{
    
    echo "You didn't press the submit button";
    
    }
    ?>
    

  2. Beacuse it is client side scripting, it isn't possible. To do it in Javascript/HTML do this.

    <script type="text/javascript">

    document.write('Javascript is enabled');

    </script>

    <noscript>Javascript is disabled</noscript>

     

     

    Or you could do this:

    You have like the page you want to show on a get statement and redirect the user with javascript. If the user isn't being redirected, then JS isn't enabled else if the user is Javascript is enabled for them

    <script type="text/javascript">

    document.location.href = "page.php?js=enabled";

    </script>

  3. <?PHP

    /*

    Basically have an animate image for a dice being roled or something. This is the basis of the script on what you can build on

    */

    if($_POST['submit']){ //if they have pressed the submit button

    $player1roll1 = rand(1,6);

    $player1roll2 = rand(1,6);

     

    $player2roll1 = rand(1,6);

    $player2roll2 = rand(1,6);

     

    $player1sum = $player1roll1 + $player1roll2;

    $player2sum = $player2roll1 + $player2roll2;

     

    if($player1sum > $player2sum){

    echo "Player 1 won";

    }elseif($player2sum > $player1sum){

    echo "Player 2 won";

    }else{

    echo "Draw";

    }

    echo '<img src="'.$player1roll1.'.jpg" />'; //echo the image for roll 1 of player 1

    echo '<img src="'.$player1roll2.'.jpg" />'; //echo the image for roll 2 of player 1

     

    echo '<img src="'.$player2roll1.'.jpg" />'; //echo the image for roll 1 of player 2

    echo '<img src="'.$player2roll2.'.jpg" />'; //echo the image for roll 2 of player 2

     

    }else{

    ?>

    <form method="post">

    <input type="submit" name="submit" value="Roll dice" />

    </form>

    <?PHP } ?>

  4. Hi,

    Can someone point me in the right direction. This is what I need to do:

    I need to choose 12 random numbers from 1 to 80 but they cant be the same.

    If I do rand(0,80) for say 12 variables there is a chance that it could be the same as one of the others.

     

    Thanks :)

×
×
  • 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.