Jump to content

benoit1980

Members
  • Posts

    35
  • Joined

  • Last visited

Posts posted by benoit1980

  1. I also tried another way as below(pure javascript) but I have a problem, I cannot get the bootstrap drop down menu staying aligned when it opens in a bootstrap column. Any idea why please?

     

    Thanks,

     

    Ben

     

     

    <!DOCTYPE html><html lang="en">  <head>    <meta content="width=device-width, initial-scale=1.0" name="viewport" />    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />  <style>.no-display {    display:none;    position:absolute;    top:50px;}.btn-group { margin: 0 auto;  text-align: center; font-size:0 !important;}.btn-group a { display:inline-block;}</style>    <br><br><br><br> <div class="container text-center extra_pages_text_black"><div class="row clearfix"><div class="col-md-12 column"> <div class="row clearfix"><div class="col-md-12 column"><h2>Choose</h2></div></div><br><br><div class="row clearfix"><div class="col-md-5 column"><a href="#" id="button1" class="btn btn-lg btn-success">BUTTON1</a></div><div class="col-md-2 column"><h2>OR</h2></div><div class="col-md-5 column"><a href="#" id="button2" class="btn btn-lg btn-success">BUTTON2</a></div></div> <div class="row clearfix" id="eatin_takeaway_drop"> <div class="col-md-12 column"> <div class="dropdown">  <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="false">    Dropdown    <span class="caret"></span>  </button>  <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li><li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li><li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li><li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li><li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li><li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li><li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li>  </ul></div>       </div></div><div class="row clearfix" id="delivery_drop"><div class="col-md-12 column">THIS IS THE RESULT OF BUTTON2</div></div></div></div></div>   <script>$("#button1").on('click', function() {   $("#eatin_takeaway_drop").fadeIn();   $("#delivery_drop").fadeOut();}); $("#button2").on('click', function() {   $("#eatin_takeaway_drop").fadeOut();   $("#delivery_drop").fadeIn();}); </script>   <!--  //CONTACTS  -->    <br><br><br><br>  <br><br><br><br>   <script src="../js/jquery/jquery-1.11.1.js"></script> 

  2. Ok, I have found an example here:

    http://jsfiddle.net/EhtrR/1135/

     

    And tried to make my own using bootstrap but all I see are my buttons and nothing else, the js is not showing or hidding the code in my div, any idea why please?

    Thanks

     

     

    <head>
      <script src="../js/jquery/jquery-1.11.1.js"></script><style>.no-display {    display:none;    position:absolute;    top:50px;}</style></head>   <script>$("#button1").on('click', function() {   $("#eatin_takeaway_drop").fadeIn();   $("#delivery_drop").fadeOut();}); $("#button2").on('click', function() {   $("#eatin_takeaway_drop").fadeOut();   $("#delivery_drop").fadeIn();}); </script>  <br><br><br><br> <div class="container"><div class="row clearfix"><div class="col-md-12 column"><div class="row clearfix"><div class="col-md-6 column"><a href="#" id="button1" class="btn btn-lg btn-success">EAT IN / TAKE AWAY</a></div><div class="col-md-6 column"><a href="#" id="button2" class="btn btn-lg btn-success">DELIVERY</a></div></div><div class="row clearfix"><div class="col-md-12 column no-display" id="eatin_takeaway_drop">HI THIS IS THE RESULT OF BUTTON1</div></div><div class="row clearfix"><div class="col-md-12 column no-display" id="delivery_drop">HI THIS IS THE RESULT OF BUTTON2</div></div></div></div></div>
     
     
    Where did I do wrong? Any idea please?
     
    Thank you,
     
    Ben
  3. Hi Everyone,

     

    Someone is asking me a bit of help on a website, I know a bit php and HTML5, I would like to know what would be the best of doing this please:

     

     

    1)I need to create 2 big buttons, according to the choice of the buttons a different dropbox menu with towns will showup.

     

    2)When the user chooses one of the town, in any drop down, I would like to show a different DIV with content in it.

     

     

    Here is a practical example:

     

       BUTTON A              BUTTON B

     

    if Button A is pressed, show dropdown menu A

    if BUTTON B is pressed, show dropdown menu B

     

    If town 1 from dropdown menu A is chosen show DIV 1

    If town 2 from dropdown menu A is chosen show DIV 1

    If town 3 from dropdown menu A is chosen show DIV 2

    If town 4 from dropdown menu A is chosen show DIV 3

    If town 5 from dropdown menu A is chosen show DIV 1

     

     

    If town 1 from dropdown menu B is chosen show DIV 6

    If town 2 from dropdown menu B is chosen show DIV 5

    If town 3 from dropdown menu B is chosen show DIV 5

    If town 4 from dropdown menu B is chosen show DIV 6

    If town 5 from dropdown menu B is chosen show DIV 4

     

     

     

     

    How to do this without reloading the page please?

     

     

     

    Thank you,

     

    Bambinou

  4. Hello,

     

    I cannot work out this one.

     

    I am loading a css file on an https page as:

    <link rel="stylesheet" type="text/css" href="/assets/fa687e60/jui/css/base/jquery-ui.css" />

     

    But using the chrome element tool I see this error:

     

    The page at 'https://mysite.com/deal/create' was loaded over HTTPS, but displayed insecure content from 'http://mysite.com/css/images/ui-bg_glass_55_fbf9ee_1x400.png': this content should also be loaded over HTTPS.

     

     

     

    Now I went in the css file and the code is like that:

    .ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight {border: 1px solid #fcefa1;background: #fbf9ee url(images/ui-bg_glass_55_fbf9ee_1x400.png) 50% 50% repeat-x;color: #363636;}
     
     
    All my images are loading that way and it seems to be causing problems on all my https pages, any idea how to fix this please?
     
    Thank you,
     
    Ben

     

     

     

     

  5. Hello,

     

     

    I am having a real problem with this and would like to know if someone can give me a feedback. Thank you

     

    I am developing a website and would like to only let the access to a few people.

    I try to lock the website with an "allow" and "disallow" htaccess block but it seems to be slowing down the website a lot.

     

    The website at the moment is hard coded with https://

     

    I am wodering if the .htaccess is correct. Sometime the pages load non stop and nothing shows up and sometime the pages are showing up.

    I remove the htaccess, everything is fine.

     

    here is the code:

     

     
    <Limit GET POST>
    order allow,deny
    allow from 89.187.79.200
    #The next line modified by DenyIP
    #deny from all
    </Limit>
    Options +FollowSymLinks
     
    IndexIgnore */*
     
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]
     
    <Files 403.shtml>
    order deny,allow
    deny from all
    </Files>
    allow from xxx.xx.xx.xxx
    ###########FaceBook###########
    Allow from 31.13.24.0/21
    Allow from 31.13.64.0/18
    Allow from 66.220.144.0/20
    Allow from 69.63.176.0/20
    Allow from 69.171.224.0/19
    Allow from 74.119.76.0/22
    Allow from 103.4.96.0/22
    Allow from 173.252.64.0/18
    Allow from 204.15.20.0/22
    Allow from 2401:db00::/32
    Allow from 2620:0:1c00::/40
    Allow from 2a03:2880::/32
    ##########FaceBook############ 
     
    


     

     

    Thanks in advance

     

     

    Ben

  6. Thank you so much jacques!!!

     

    I cannot believe I missed that one, it is because I change the row name in the database and totally forgot about it...dang!

     

    I am still on my beginner courses so mistakes will still be made for many years :-)

     

    What I would like to ask you please is to tell me if my way of storing the url path is correct or right for a coder, at the moment it is saving fine, I have added a bit of code on the $path.

     

    In the database it saved my picture as "uploads/10566448_749876155095516_711706263_n.jpg"

     

    Perhaps I should add a random generated function that gives different picture names each time? I am not sure if I am going in the right direction to be honest....

     

     <?php include "../common/header_admin.php"; ?> <?php include '../conn/db_connect.php'; ?>                <!-- Navigation -->        <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">            <div class="navbar-header">                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">                    <span class="sr-only">Toggle navigation</span>                 </button>                <a class="navbar-brand" href="index.html">PizzaByLuca.com</a>            </div>            <!-- /.navbar-header -->             <ul class="nav navbar-top-links navbar-right">                 <!-- /.dropdown -->                <li class="dropdown">                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">                        <i class="fa fa-user fa-fw"></i>  <i class="fa fa-caret-down"></i>                    </a>               <?php include '../admin/login_area.php'; ?>                          </li>                     </ul>                      <!--Left Side Navigation Menu Starts-->            <div class="navbar-default sidebar" role="navigation">                <div class="sidebar-nav navbar-collapse">                    <ul class="nav" id="side-menu">                        <li class="sidebar-search">                            <div class="input-group custom-search-form">                                <input type="text" class="form-control" placeholder="Search...">                                <span class="input-group-btn">                                <button class="btn btn-default" type="button">                                    <i class="fa fa-search"></i>                                </button>                            </span>                            </div>                                                    </li>                        <li>                            <a class="active" href="#"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a>                        </li> <!--Menu Include Starts -->                        <?php include '../admin/left_side_menus.php'; ?>                        <!--Menu Include Ends -->                    </ul>                </div>                           </div><!--Left Side Navigation Menu End-->                    </nav>         <div id="page-wrapper">            <div class="row">                <div class="col-lg-12">                    <h1 class="page-header"></h1>                </div>            </div> <!--Content Here--><?php$action = isset( $_POST['action'] ) ? $_POST['action'] : "";        if($action == "create"){        try{$query = "INSERT INTO top_picture_slider SET title = ?, desc_medium = ?, desc_small = ?, image = ?";         $path = "uploads/" . $_FILES['image']['name'];        move_uploaded_file($_FILES['image']['tmp_name'], "../".$path);   $title = sanitize($_POST['title']);       $desc_medium = sanitize($_POST['desc_medium']);       $desc_small = sanitize($_POST['desc_small']);  $image = $path;         //prepare query for execution        $stmt = $con->prepare($query);         //this is the first question mark        $stmt->bindParam(1, $_POST['title']);         //this is the second question mark        $stmt->bindParam(2, $_POST['desc_medium']);         //this is the third question mark        $stmt->bindParam(3, $_POST['desc_small']);         //this is the fourth question mark        $stmt->bindParam(4, $image);           // Execute the query        if($stmt->execute()){            echo "<div class='alert alert-success' role='alert'>Record was added!.</div>";        }else{            die("<div class='alert alert-danger' role='alert'>Unable to update record!</div>");        }             }catch(PDOException $exception){ //to handle error        echo "Error: " . $exception->getMessage();    }}?>  <!--we have our html form here where user information will be entered--><form action="#" method="post" enctype="multipart/form-data"><input type="hidden" name="MAX_FILE_SIZE" value="100000" /><input type="text" class="form-control" placeholder="Add Your Title" size="100" name="title" /><br /><br /><textarea cols="50" class="form-control" rows="10" wrap="virtual" maxlength="150" placeholder="Add Your Medium Description" name="desc_medium"></textarea><br /><br /><textarea cols="50" class="form-control" rows="10" wrap="virtual" maxlength="100" placeholder="Add Your Small Description" name="desc_small"></textarea><br /><br /><input type="file" name="image" class="btn btn-default btn-lg" /><br /><br /><input type="hidden" name="action" value="create" /><input class="btn btn-primary btn-lg" type="submit" value="save" /><br /><br /></form>    <!--Content Here-->  <?php include '../common/footer_admin.php'; ?> 

     
     
    Thanks,
     
    Ben
  7. Hello everyone,

     

    I would like to upload an image to a directory and keep it's path saved in mysql.

    Some people proposed me in the past to save the image directly in mysql but others were totally against it.

     

    Here is my code, remember, it is connecting properly and at the moment what I receive in the "image" row of mysql is "uploads/" but no image name at all.

     

    Don't worry about the form validation as of yet, I am just trying to understand the principle at the moment, I will do the form validation later on.

     

    Thanks in advance for your help.(I did not include the connection file as it is connecting well)

    The error I am also currently receiving is:

    Error: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'image' cannot be null

     

    <?php include "../common/header_admin.php"; ?>
     <?php include '../conn/db_connect.php'; ?>
           
    
            <!-- Navigation -->
            <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="sr-only">Toggle navigation</span>
    
                    </button>
                    <a class="navbar-brand" href="index.html">PizzaByLuca.com</a>
                </div>
                <!-- /.navbar-header -->
    
                <ul class="nav navbar-top-links navbar-right">
    
                    <!-- /.dropdown -->
                    <li class="dropdown">
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                            <i class="fa fa-user fa-fw"></i>  <i class="fa fa-caret-down"></i>
                        </a>
                   
                 <?php include '../admin/login_area.php'; ?>
              
                    </li>
             
                </ul>
              
                <!--Left Side Navigation Menu Starts-->
                <div class="navbar-default sidebar" role="navigation">
                    <div class="sidebar-nav navbar-collapse">
                        <ul class="nav" id="side-menu">
                            <li class="sidebar-search">
                                <div class="input-group custom-search-form">
                                    <input type="text" class="form-control" placeholder="Search...">
                                    <span class="input-group-btn">
                                    <button class="btn btn-default" type="button">
                                        <i class="fa fa-search"></i>
                                    </button>
                                </span>
                                </div>
                                
                            </li>
                            <li>
                                <a class="active" href="#"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a>
                            </li>
                            
                            <!--Menu Include Starts -->
                            <?php include '../admin/left_side_menus.php'; ?>
                            <!--Menu Include Ends -->
                        </ul>
                    </div>
                   
                </div>
                <!--Left Side Navigation Menu End-->
                
            </nav>
    
            <div id="page-wrapper">
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header"></h1>
                    </div>
                </div>
    
    <!--Content Here-->
    <?php
    $action = isset( $_POST['action'] ) ? $_POST['action'] : "";
            if($action == "create"){
            try{
                 $query = "INSERT INTO top_picture_slider SET title = ?, desc_medium = ?, desc_small = ?, image = ?";
           
           $title = sanitize($_POST['title']);
           $desc_medium = sanitize($_POST['desc_medium']);
           $desc_small = sanitize($_POST['desc_small']);
           $image = $_FILES["file"]["name"];
            
            //prepare query for execution
            $stmt = $con->prepare($query);
     
            //this is the first question mark
            $stmt->bindParam(1, $_POST['title']);
     
            //this is the second question mark
            $stmt->bindParam(2, $_POST['desc_medium']);
     
            //this is the third question mark
            $stmt->bindParam(3, $_POST['desc_small']);
     
            //this is the fourth question mark
            $stmt->bindParam(4, $_FILES["file"]["name"]);
           
    
            // Execute the query
            if($stmt->execute()){
                echo "<div class='alert alert-success' role='alert'>Record was added!.</div>";
            }else{
                die("<div class='alert alert-danger' role='alert'>Unable to update record!</div>");
            }
             
        }catch(PDOException $exception){ //to handle error
            echo "Error: " . $exception->getMessage();
        }
    }
    ?>
    
     
    <!--we have our html form here where user information will be entered-->
    <form action="#" method="post" enctype="multipart/form-data">
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
    <input type="text" class="form-control" placeholder="Add Your Title" size="100" name="title" /><br /><br />
    <textarea cols="50" class="form-control" rows="10" wrap="virtual" maxlength="150" placeholder="Add Your Medium Description" name="desc_medium"></textarea><br /><br />
    <textarea cols="50" class="form-control" rows="10" wrap="virtual" maxlength="100" placeholder="Add Your Small Description" name="desc_small"></textarea><br /><br />
    <input type="file" name="image" class="btn btn-default btn-lg" /><br /><br />
    <input type="hidden" name="action" value="create" />
    <input class="btn btn-primary btn-lg" type="submit" value="save" /><br /><br />
    </form>
    
    
    
    
    <!--Content Here-->
    
    
    <?php include '../common/footer_admin.php'; ?>
     
    

     

     

     

     

     

     

     

  8. Thank you ,

     

    I will check this later on.

    The reason I must disable https for this particular page is because I am using an affiliate that shows hotels people can book.

    For the affiliate to work I had to point the CNAME of a subdomain they asked me to create as:

    hotels.mysite.com to --> Affiliate.hotels.com

     

    Now imagine that this sub points to the subdomain and the user cannot see anything else in the browser rather than hotels.mysite.com.

     

    The next problem was to incorporate this hotel searchin the framework to fit with the rest of the rest, I was force to use an iframe but as you know,

    the iframe will be outputting an http url inside a site that is fully https.

    Due to this problem, the iframe shows a blankpage.......

     

     

    I hope you understand.

     

    Regards,

     

    Ben

  9. Hi All,

     

    I would like to know if someone could help me with this, I have been struggling for days and cannot find an answer.

    I am new to OOP and still struggle a bit with the logic.

     

    I have installed Yii2 on my local machine, all I want is insert a date in the correct format in the database as:

    DD/MM/YYYY

     

    I cannot believe how hard it is just ti work this one out as a beginner.......

     

    I tried this:

    http://www.yiiframework.com/doc-2.0/guide-behaviors.html:

     

    And added this code inmy Posts Model:

     

     

    use yii\behaviors\TimestampBehavior;
    
    class User extends ActiveRecord
    {
        // ...
    
        public function behaviors()
        {
            return [
                'timestamp' => [
                    'class' => TimestampBehavior::className(),
                    'attributes' => [
                        ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
                        ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at',
                    ],
                ],
            ];
        }
    }
     
    

     

     

    I have the corresponding database fields as created_at and updated_at set as INT.

     

     

    Unfortunately, when I try to save my form I get this error:

    PHP Fatal Error – yii\base\ErrorException Class 'app\models\ActiveRecord' not found1. in C:\wamp\www\yii2\models\posts.php at line 61    } public function behaviors()    {        return [            'timestamp' => [                'class' => TimestampBehavior::className(),                'attributes' => [                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at',                ],            ],        ];    }   }
     
    

     

     

    Any idea why please?I have followed the Yii website tutorial correctly but still cannot get the date input to work.

     

     

    Thank you,

     

     

    Regards,

     

    Ben

     

  10. Hi everyone,

     

    I am starting to learn PHP OOP and would like to know if you could help me understanding the scopes a little bit better.

     

    I have created the below code during my courses, but cannot work out how to reuse   $this->total in another class.

    I have set the $total; to protected and was wishing to be able to use it in my second class but it returned an error.

     

    Any idea how I could use this variable in another class while set with the scope of Protected please?

     

    Thank you so much!

       Class Calculator{     public $number1;    public $number2;    protected $total;        function setNumber1($int){              $this->number1 = (int) $int;             }        function setNumber2($int){              $this->number2 = (int) $int;             }        function Calculate(){                $this->total = $this->number1 + $this->number2;                        }        function getResult(){                    return $this->total;                    }   }     $Calculator = new Calculator();    $Calculator->setNumber1(5);    $Calculator->setNumber2(10);    $Calculator->Calculate();    echo $Calculator->getResult() . "<br>";         Class secondCalculator extends Calculator    {               $this->total = $this->number3 + $this->number4;                }     
    

     

     

    Ben

  11. Hello

     

    I would like to know what is wrong in my code please, everything appear on the screen without mysql connection error when I remove all the php that starts from mysqli_query at the bottom of the page. When I remove all the code I have noted with #################### the form shows up on the screen, when I re-add that code, the page is white therefore there is something wrong I am doing here.

    Could you please let me know? Thank you. Regarding the id, someone told me to leave it blank in the query as it is auto incremented.

     

    Ben

     

     

    <?php include "/include/header.php"; ?><?php include "/include/navbar.php"; ?><?php include "/connect/connect.php"; ?>  <?phpif(isset($_POST['submit'])) {$name = $_POST['name'];  $surname = $_POST['surname'];  $username = $_POST['username'];  $password1 = $_POST['password1'];$password2 = $_POST['password2'];$email = $_POST['email'];  if(empty($name)){  echo "Please add Your name to the form<br>";  }elseif (strlen($name)<3){   echo "Your name is way too short, please input a real name!<br>"; }if(empty($surname)){  echo "Please add Your Surname to the form<br>";  }elseif (strlen($surname)<3){   echo "Your surname is way too short, please input a real surname!<br>"; }if(empty($username)){  echo "Please choose a Username<br>";  }elseif (strlen($username)<5){   echo "Your Username should have a minimum of 5 characters!<br>"; }if(empty($email)){  echo "Input an email<br>";  }if(empty($password1)){  echo "Please choose a password<br>";  }elseif (strlen($password1)<5){   echo "Your password should have at least 5 characters or digits!<br>"; }if($password1 !== $password2){  echo "Your passwords do not match, please verify your passwords<br>";  }else{ $safe_name = mysqli_real_escape_string($name);$safe_surname = mysqli_real_escape_string($surname);$safe_username = mysqli_real_escape_string($username);$safe_email = mysqli_real_escape_string($email);$safe_password = mysqli_real_escape_string($password);$safe_email = mysqli_real_escape_string($email);}?>   <div class="container centered"> <form role="form" name="registration" method="post" action="">   <div class="form-group">    <label>Your Name</label>    <input type="text" name="name" class="form-control custom" placeholder="Enter your Name" value="<?php echo $_POST['name']; ?>">  </div>    <div class="form-group">    <label>Your Surname</label>    <input type="text" name="surname" class="form-control custom"  placeholder="Enter your Surname" value="<?php echo $_POST['surname']; ?>">  </div>  <div class="form-group">    <label>Choose a Username</label>    <input type="text" name="username" class="form-control custom"  placeholder="Enter your Username" value="<?php echo $_POST['username']; ?>">  </div>  <div class="form-group">    <label>Choose a Password</label>    <input type="password" name="password1" class="form-control custom"  placeholder="Choose your Password">  </div>  <div class="form-group">    <label>Retype your Password</label>    <input type="password" name="password2" class="form-control custom"  placeholder="Re-enter your Password">  </div>    <div class="form-group">    <label>Your email</label>    <input type="email" name="email" class="form-control custom"  placeholder="Enter your Email" value="<?php echo $_POST['email']; ?>">  </div>  <input type="submit" name="submit" class="btn btn-default" value="submit"></form>  ############################<?php // Create the Database Querymysqli_query('INSERT INTO users (id, name, name, surname, username, password, email) VALUES ( , $safe_name, $safe_surname, $safe_username, $safe_email, $safe_password, $safe_email)'); // Test if there was a query errorif (!$connection) {    die("Database query failed.");}  // Close database connection mysqli_close($connection);{  echo "Your form has been submitted!"; }}?>################################</div>       <?php include "/include/footer.php"; ?>
     
     
    

  12. Hi everyone,

     

    I have been for hours on this and decided to help some help from you at PHPFreak because I just cannot work it out.

    I am new to PHP and created by first project last night downloading bootstrap 3.

     

    To explain the matter faster, all I need to know if how certain scripts can be uploaded both on a remote server and local server without broken css paths and others.

    At the moment the $_SERVER['DOCUMENT_ROOT'] in my css files and include files are returning:
    C:/wamp/www/

    But should return
    C:/wamp/www/project_name

    Any idea why and how to change this problem please?
     
    Now I could for sure hardcore the  C:/wamp/www/project_name path but it will kind of kill the idea of seeing in working on local and remote server easily.
     
    Could you please let me know if you have a trick for this please?
     
     
    My folders order is(inside C:/wamp/www/project_name):
     
     
    bootstrap
    functions
    include
    public
    index.php
    admin
     


    Thank you,

    Ben
     

     

  13. Hi all,

     

     

    I am currently learning PHP and would need a bit of help to get me started please.

     

    I have created a simple form with my css and try to add a PHP validation, everything is working perfectly except the last part of my validation. The password comparison is not working, any idea please? I do not even see the error.

     

     

     

      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="application/x-www-form-urlencoded">
      <label class="control-label" for="input01">Username</label>
      <div class="controls"><input type="text" name="username" value="<?php echo htmlspecialchars($_POST['username']); ?>" class="input-xlarge" style="width:285px; padding:10px;" id="input01" /></div>
      <label class="control-label" for="input01">Email</label>
      <div class="controls"><input type="text" name="email" value="<?php echo htmlspecialchars($_POST['email']); ?>" class="input-xlarge" style="width:285px; padding:10px;" id="input01" /></div>
      <label class="control-label" for="input01">Password</label>
      <div class="controls"><input type="password" name="password" value="<?php echo htmlspecialchars($_POST['password']); ?>" class="input-xlarge" style="width:285px; padding:10px;" id="input01" /></div>
      <label class="control-label" for="input01">Confirm Password</label>
      <div class="controls"><input type="password" name="confirm_password" value="<?php echo htmlspecialchars($_POST['confirm_password']); ?>" class="input-xlarge" style="width:285px; padding:10px;" id="input01" /></div>
      <button type="submit" value="submit" name="submit" style="width:100%;" class="large lightblue button radius" >Submit</button>
      </form>
     
  14. In fact my first problem was really stupid, I did not have a connection :-)

     

    But my second problem is that the sql command i actually invalid and returning nothing like that

    SELECT * FROM vipsreg WHERE phone_number=0035679303062 AND group_leader IS NULL;

     

    But returning the right row like this:

    SELECT * FROM vipsreg WHERE phone_number=0035679303062

     

    Unfortunately I must have the results return for the phone number field if there is a null value found in the group_leader field...;

  15. Hi PaulRyan,

     

    Thank you for your help, here it is:

     

    <?php
     
    $prefixphone = $_POST['prefix'].$_POST['phone'];
      $stmt = $mysqli->prepare("SELECT * FROM $tbl_name WHERE phone_number=? AND group_leader IS NULL");                          /* Bind our params */                                                                        $stmt->bind_param('s', $prefixphone);                          /* Execute it */                         $result = $stmt->execute();                         $stmt->store_result();                          if ($stmt->num_rows == 1)                        {                              echo '<div align="center" class="text-not-correct">You are a top member!</div>';                              /* Close statement */                             $stmt->close();                              /* Close connection */                             $mysqli->close();                          } else {                 echo '<div align="center" class="text-not-correct">You are not a top member!</div>';                    echo '<div align="center" class="text-not-correct">This is the end</div>';                }
     
    ?>
    

  16. Hi,

     

    Thank you for your help, unfortunately I am still getting error:

     

    Fatal error: Call to a member function prepare() on a non-object in /check.php on line 25

     

     

    Line 25 corresponding to 

     

    $stmt = $mysqli->prepare("SELECT * FROM $tbl_name WHERE phone_number=? AND group_leader IS NULL");

     

     

    Any idea what it means please? When I remove this part of the query:

    AND group_leader IS NULL

     

     

    It seems that the NULL value is causing problem.

    IS WORKS OK....WEIRD...

     

    Thank you,

     

    Ben

  17. Hello,

     

    I have no idea what I am doing wrong.

     

    I am trying to return the matching $prefixphone value only if there is a "null" value found in the column. I have been stuck on this for 2 hours, I cannot find a solution.

     

    please help,

     

    Thank you,

     

    Ben

    <?php
                             $stmt = $mysqli->prepare("SELECT * FROM $tbl_name WHERE phone_number=? AND  WHERE group_leader=?");                          /* Bind our params */                        $prefixphone = '987979879';                        $group_leader ='IS NULL';                        $stmt->bind_param('ss', $prefixphone, $group_leader);                          /* Execute it */                         $result = $stmt->execute();                         $stmt->store_result();                          if ($stmt->num_rows == 1)                        {                              echo '<div align="center" class="text-not-correct">You are a VIP member!</div>';                              /* Close statement */                             $stmt->close();                              /* Close connection */                             $mysqli->close(); ?>
×
×
  • 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.