-
Posts
84 -
Joined
-
Last visited
Posts posted by PHPTOM
-
-
<?PHP $string = "JoeBloggs"; $spliter = split(",",substr(preg_replace("/([A-Z])/",',\\1',$string),1)); $forename = $spliter[0]; $surname = $spliter[1]; ?>
This can also be used if $string = "JoeBloggsWithMoreCaps";
-
Nope. Just have a file with the class in and save as PHP. Some people have file.inc.php or something so they know that file is being included somewhere.
-
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"; } ?>
-
Yeah. When they login, you would check them against a database table, then if successfull set a cookie or a session. If you need help in that area, create a new topic.
-
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>
-
<?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 } ?>
-
Thanks a lot
-
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
[SOLVED] how to save a class file?
in PHP Coding Help
Posted
But really its personal preference