www.webdeveloper.com
Results 1 to 3 of 3

Thread: Execute the code

Hybrid View

  1. #1
    Join Date
    Jul 2013
    Posts
    5

    Execute the code

    I have the following example code
    <?php
    $Fname = $_POST["Fname"];
    $Lname = $_POST["Lname"];
    $gender = $_POST["gender"];
    $food = $_POST["food"];
    $quote = $_POST["quote"];
    $education = $_POST["education"];
    $TofD = $_POST["TofD"];
    if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
    ?>
    <html>
    <head>
    <title>Personal INFO</title>
    </head>
    <body>
    <form method="post" action="<?php echo $PHP_SELF;?>">
    First Name:<input type="text" size="12" maxlength="12" name="Fname"><br />
    Last Name:<input type="text" size="12" maxlength="36" name="Lname"><br />
    Gender:<br />
    Male:<input type="radio" value="Male" name="gender"><br />
    Female:<input type="radio" value="Female" name="gender"><br />
    Please choose type of residence:<br />
    Steak:<input type="checkbox" value="Steak" name="food[]"><br />
    Pizza:<input type="checkbox" value="Pizza" name="food[]"><br />
    Chicken:<input type="checkbox" value="Chicken" name="food[]"><br />
    <textarea rows="5" cols="20" name="quote" wrap="physical">Enter your favorite quote!</textarea><br />
    Select a Level of Education:<br />
    <select name="education">
    <option value="Jr.High">Jr.High</option>
    <option value="HighSchool">HighSchool</option>
    <option value="College">College</option></select><br />
    Select your favorite time of day:<br />
    <select name="TofD" size="3">
    <option value="Morning">Morning</option>
    <option value="Day">Day</option>
    <option value="Night">Night</option></select><br />
    <input type="submit" value="submit" name="submit">
    </form>
    <?
    } else {
    echo "Hello, ".$Fname." ".$Lname.".<br />";
    echo "You are ".$gender.", and you like ";
    foreach ($food as $f) {
    echo $f."<br />";
    }
    echo "<i>".$quote."</i><br />";
    echo "You're favorite time is ".$TofD.", and you passed ".$education."!<br />";
    }
    ?>

    The url does not respond, What needs to change in the following code.

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,198
    Line 39 is <? when it should be <?php

    When that is fixed, my server outputs the following errors.

    Notice: Undefined index: Fname in C:\XAMPP\htdocs\forms.php on line 2
    Notice: Undefined index: Lname in C:\XAMPP\htdocs\forms.php on line 3
    Notice: Undefined index: gender in C:\XAMPP\htdocs\forms.php on line 4
    Notice: Undefined index: food in C:\XAMPP\htdocs\forms.php on line 5
    Notice: Undefined index: quote in C:\XAMPP\htdocs\forms.php on line 6
    Notice: Undefined index: education in C:\XAMPP\htdocs\forms.php on line 7
    Notice: Undefined index: TofD in C:\XAMPP\htdocs\forms.php on line 8

    So....

    What I did was change this

    PHP Code:
    <?php
    $Fname 
    $_POST["Fname"];
    $Lname $_POST["Lname"];
    $gender $_POST["gender"];
    $food $_POST["food"];
    $quote $_POST["quote"];
    $education $_POST["education"];
    $TofD $_POST["TofD"];
    if (!isset(
    $_POST['submit'])) { // if page is not submitted to itself echo the form
    ?>
    to this

    PHP Code:
    <?php
    if (isset($_POST['submit'])) { // if page is not submitted to itself echo the form
    $Fname $_POST["Fname"];
    $Lname $_POST["Lname"];
    $gender $_POST["gender"];
    $food $_POST["food"];
    $quote $_POST["quote"];
    $education $_POST["education"];
    $TofD $_POST["TofD"];

    echo 
    "Hello, ".$Fname." ".$Lname.".<br />";
    echo 
    "You are ".$gender.", and you like ";
    foreach (
    $food as $f) {
    echo 
    $f."<br />";
    }
    echo 
    "<i>".$quote."</i><br />";
    echo 
    "You're favorite time is ".$TofD.", and you passed ".$education."!<br />";

    }else{
    ?>
    and I changed this
    PHP Code:
    <?
    } else {
    echo 
    "Hello, ".$Fname." ".$Lname.".<br />";
    echo 
    "You are ".$gender.", and you like ";
    foreach (
    $food as $f) {
    echo 
    $f."<br />";
    }
    echo 
    "<i>".$quote."</i><br />";
    echo 
    "You're favorite time is ".$TofD.", and you passed ".$education."!<br />";
    }
    ?>
    to this
    PHP Code:
    <?php
    }
    ?>
    Then I get no errors.

    I do seriously advise that you look in to how to properly sanitize inputs, the subject is searchable on this forum and forgive me for not giving an example but reinventing the wheel I am not about to do.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  3. #3
    Join Date
    Sep 2012
    Posts
    720
    Hi....In computer security, arbitrary code execution is used to describe an attacker's ability to execute any commands of the attacker's choice on a target machine or in a target process. It is commonly used in arbitrary code execution vulnerability to describe a software bug that gives an attacker a way to execute arbitrary code. A program that is designed to exploit such a vulnerability is called an arbitrary code execution exploit. Most of these vulnerabilities allow the execution of machine code and most exploits therefore inject and execute shellcode to give an attacker an easy way to manually run arbitrary commands. The ability to trigger arbitrary code execution from one machine on another (especially via a wide-area network such as the Internet) is often referred to as remote code execution.

    It is the worst effect a bug can have because it allows an attacker to completely take over the vulnerable process. From there the attacker can potentially take complete control over the machine the process is running on. Arbitrary code execution vulnerabilities are commonly exploited by malware to run on a computer without the owner's consent or by an owner to run homebrew software on a device without the manufacturer's consent.

    Arbitrary code execution is commonly achieved through control over the program counter (also known as the instruction pointer) of a running process. The instruction pointer points to the next instruction in the process that will be executed. Control over the value of the instruction pointer therefore gives control over which instruction is executed next. In order to execute arbitrary code, many exploits inject code into the process (for example by sending input to it which gets stored in an input buffer) and use a vulnerability to change the instruction pointer to have it point to the injected code. The injected code will then automatically get executed.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles