Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19
  1. #11
    Join Date
    Sep 2008
    Location
    UK
    Posts
    3,670
    Tokens
    0

    Latest Awards:

    Default

    Here is function.php:
    PHP Code:
    function secure($string) {
    $string mysql_real_escape($string);
    $string stripslashes($string);
    return 
    $string;

    PHP Code:
    <?php

    include 'function.php';

    $host "dbhost";
    $dbuser "dbuser";
    $dbpass "dbpass";
    $dbname "dbname";

    $con mysql_connect("$host","$dbuser","$dbpass")
    or die(
    mysql_error());

    mysql_select_db("$dbname",$con)
    or die(
    mysql_error());

    if ( isset(
    $_POST['contact'] )) {
        if ( empty(
    $full) || empty($adr1) || empty($adr2) || empty($town) || empty($county) || empty($postcode) || empty($email) || empty($sprod) || empty($squant) ) {
            die(
    'A mandatory field has been left empty.');
        } else {
            
    $full secure($_POST['full']);
            
    $adr1 secure($_POST['adr2']);
            
    $adr2 secure($_POST['adr2']);
            
    $town secure($_POST['town']);
            
    $county secure($_POST['county']);
            
    $postcode secure($_POST['postcode']);
            
    $telnum secure($_POST['telnum']);
            
    $email secure($_POST['email']);
            
    $por secure($_POST['por']);
            
    $sprod secure($_POST['sprod']);
            
    $squant secure($_POST['squant']);
            
    $extras secure($_POST['extras']);
            
    $remarks secure($_POST['remarks']);
            
            
    $insert mysql_query("INSERT INTO `dbname` (`full`,`adr1`,`adr2`,`town`,`county`,`postcode`,`postcode`,`telnum`,`email`,`por`,`sprod`,`squant`,`extras`,`remarks`) VALUES ('$full','$adr1','$adr2','$town','$county','$postcode','$telnum','$email','$por','$sprod','$squant','$extras','$remarks')")
            or die(
    mysql_error());
            
            echo 
    "Form sent";
        }
    } else {
        echo 
    "PUT FORM HERE";
    }

    ?>
    Back for a while.

  2. #12
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Excellent2 View Post
    Here is function.php:
    PHP Code:
    function secure($string) {
    $string mysql_real_escape($string);
    $string stripslashes($string);
    return 
    $string;

    PHP Code:
    <?php

    include 'function.php';

    $host "dbhost";
    $dbuser "dbuser";
    $dbpass "dbpass";
    $dbname "dbname";

    $con mysql_connect("$host","$dbuser","$dbpass")
    or die(
    mysql_error());

    mysql_select_db("$dbname",$con)
    or die(
    mysql_error());

    if ( isset(
    $_POST['contact'] )) {
        if ( empty(
    $full) || empty($adr1) || empty($adr2) || empty($town) || empty($county) || empty($postcode) || empty($email) || empty($sprod) || empty($squant) ) {
            die(
    'A mandatory field has been left empty.');
        } else {
            
    $full secure($_POST['full']);
            
    $adr1 secure($_POST['adr2']);
            
    $adr2 secure($_POST['adr2']);
            
    $town secure($_POST['town']);
            
    $county secure($_POST['county']);
            
    $postcode secure($_POST['postcode']);
            
    $telnum secure($_POST['telnum']);
            
    $email secure($_POST['email']);
            
    $por secure($_POST['por']);
            
    $sprod secure($_POST['sprod']);
            
    $squant secure($_POST['squant']);
            
    $extras secure($_POST['extras']);
            
    $remarks secure($_POST['remarks']);
            
            
    $insert mysql_query("INSERT INTO `dbname` (`full`,`adr1`,`adr2`,`town`,`county`,`postcode`,`postcode`,`telnum`,`email`,`por`,`sprod`,`squant`,`extras`,`remarks`) VALUES ('$full','$adr1','$adr2','$town','$county','$postcode','$telnum','$email','$por','$sprod','$squant','$extras','$remarks')")
            or die(
    mysql_error());
            
            echo 
    "Form sent";
        }
    } else {
        echo 
    "PUT FORM HERE";
    }

    ?>
    How come u stripped slashes after mysql escape string?

  3. #13
    Join Date
    Sep 2008
    Location
    UK
    Posts
    3,670
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Jackboy View Post
    How come u stripped slashes after mysql escape string?
    Habit
    Back for a while.

  4. #14

    Default

    TY - but,

    I don't get what you've done with the MySQL, it says sprod and squant, but im unsureif this is correct or not...

  5. #15
    Join Date
    Sep 2008
    Location
    UK
    Posts
    3,670
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Thai-Man-Land View Post
    TY - but,

    I don't get what you've done with the MySQL, it says sprod and squant, but im unsureif this is correct or not...
    Sprod and squant are short for Select Product & Select Quantity.
    Back for a while.

  6. #16

    Default

    I can't get it to work still.

    I'm sure I saw somewhere that a form action could be 'self'

  7. #17
    Join Date
    Sep 2008
    Location
    UK
    Posts
    3,670
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Thai-Man-Land View Post
    I can't get it to work still.

    I'm sure I saw somewhere that a form action could be 'self'
    $_SERVER[PHP_SELF]
    Back for a while.

  8. #18

    Default

    And I just use that in my code somewhere?

  9. #19
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Thai-Man-Land View Post
    And I just use that in my code somewhere?
    Yeh you wanna use it after <?php really.

Page 2 of 2 FirstFirst 12

Posting Permissions

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