why this script is not wroking?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

why this script is not wroking?

Post by Maluendaster »

First of all, I'm a newby and i know i have like 30+ errors in this code.... I wanted to make a form where the user enter a numbers , and if the user enter the right number, it says he won, if he didn't enter the same number it says he lost, and if he enter nothing, display something like "You didn't entered any numbers"....

here's the code :

Code: Select all

<?php
$premio = 123456;
$codigo = $_POST['codigo'];
//////////////////////////////////////
if (isset($_POST['codigo'])) {
echo "No ingresaste ningun codigo";
}else{
if ($_POST['codigo'] == $premio) {
echo "GANASTE!! llama al siguiente telefono para confirmar tus datos!!";
}else{
echo "No ganaste, pero sigue intentando!"; }
?>
thank you
AshrakTheWhite
Forum Commoner
Posts: 69
Joined: Thu Feb 02, 2006 6:47 am

Post by AshrakTheWhite »

Code: Select all

<?php
$premio = '123456';
$codigo = $_POST['codigo'];
//////////////////////////////////////
if (empty($_POST['codigo'])) 
{
    echo "No ingresaste ningun codigo"; //nothing entered
}   else
    {
        if ($_POST['codigo'] == $premio) 
        {
            echo "GANASTE!! llama al siguiente telefono para confirmar tus datos!!"; // = 123456
        }   else
            {
                echo "No ganaste, pero sigue intentando!"; // != 123456
            }
    }
?>
Last edited by AshrakTheWhite on Mon Apr 24, 2006 2:06 am, edited 1 time in total.
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

solution

Post by dibyendrah »

Dear Ashrak,
You forgot to put the ending bracket of else.

Code: Select all

<?php
$premio = 123456;
$codigo = $_POST['codigo'];

if (isset($_POST['codigo'])) {
echo "No ingresaste ningun codigo";
}else{
if ($_POST['codigo'] == $premio) {
echo "GANASTE!! llama al siguiente telefono para confirmar tus datos!!";
}else{
echo "No ganaste, pero sigue intentando!"; 
}
}  <- You forgot to add this bracket
?>
Cheers,
Dibyendra
AshrakTheWhite
Forum Commoner
Posts: 69
Joined: Thu Feb 02, 2006 6:47 am

Post by AshrakTheWhite »

Doh sorry :p its 9am hehehehe
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Post by Maluendaster »

thank you!
Post Reply