Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Regular Coder
    Join Date
    Aug 2013
    Posts
    196
    Thanks
    14
    Thanked 0 Times in 0 Posts

    How from input html pass data in php page

    I am making booking system and i have problem,my information's (startdate,endDate,rooms,adult and kids)won't display on another page.

  • #2
    Regular Coder
    Join Date
    Sep 2011
    Posts
    428
    Thanks
    18
    Thanked 26 Times in 26 Posts
    What are you doing with the data? Are you saving it to a database or a text file? A database would be better and more organized, but a text file could be moved around easily (if you need to a lot), such as saving it on a flash drive and moving between systems.

  • #3
    Regular Coder
    Join Date
    Aug 2013
    Posts
    196
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dubz View Post
    What are you doing with the data? Are you saving it to a database or a text file? A database would be better and more organized, but a text file could be moved around easily (if you need to a lot), such as saving it on a flash drive and moving between systems.
    I saving them in datebase.and use post variables to dispaly results.

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Need more info.
    Show us some scripting you've done that doesn't work.

  • #5
    Regular Coder
    Join Date
    Sep 2011
    Posts
    428
    Thanks
    18
    Thanked 26 Times in 26 Posts
    Don't use post variables to display results, you should get the data from the database. The $_POST only works when you submit data, after that it's not there. You need to grab the information from the database and display it how you'd like to, whether in a table or something else.

  • #6
    Regular Coder
    Join Date
    Aug 2013
    Posts
    196
    Thanks
    14
    Thanked 0 Times in 0 Posts
    [/PHP]
    Quote Originally Posted by mlseim View Post
    Need more info.
    Show us some scripting you've done that doesn't work.
    PHP Code:

    // Get values from form 
    $startDate=$_POST['startDate'];
    $endDate=$_POST['endDate'];

    $rooms=$_POST['rooms'];
    $kids=$_POST['kids'];
    $adult=$_POST['adult'];
    // Insert data into mysql 

    $sql="INSERT INTO adult(startDate,endDate, rooms, kids,adult,numberdays)VALUES('$startDate','$endDate', '$rooms', '$kids','$adult','$numberdays')";
    $result=mysql_query($sql);



        


    if($result){
    echo "succesfull";
    echo "<BR>";
    echo "<a href=''></a>";
    }

    else {
    echo "ERROR";
    }




        





    ?> 



    <?php
       $db 
    mysql_connect("","","");
       if(!
    $db) die("Error connecting to MySQL database.");
       
    mysql_select_db("" ,$db);
    ?>



    <p>Sada ste u datoteci 2s.php </p>
    <?php 
    $texts 
    $_POST['ime'];
     echo 
    "IME je $texts <br/>";
    $texts2 $_POST['prezime'];
      echo 
    "PREZIME je $texts2 <br/>";
    $x$_POST['name2'];
    ?>




    <h2>
    <div align =center>
    </h2>
    <div align =center>
    <h2>

    ><style type='text/css'>  
      body {
        font-size: 11px;
        background-color: #000;
      }
    razmak {
    }
      razmak {
        clip: rect(600px,auto,200px,auto);
    }
    </style>

    ><style type="text/css">
    center {
        margin-right: auto;
        margin-left: 2000px;
        font-weight: 900;
        font-size: xx-large;
        clip: rect(50px,auto,300px,500px);
    }
    .center2 {
        margin-right: auto;
        margin-left: auto;
        clip: rect(50px,auto,500px,auto);
    }
    razmak {
        clip: rect(auto,400px,auto,60px);
    }
    center slova {
        clip: rect(auto,400px,auto,60px);
    }
    body,td,th {
        color: #006;
    }
    body {
        background-color: #000;
        color: #999;
    }
    h3 {
        color: #006;
        background-color: #000;
    }
    h1 {
        color: #006;
    }
    h2 {
        color: #000;
        background-color: #000;
    }
    h4 {
        color: #006;
    }
    h5 {
        color: #006;
    }
    h6 {
        color: #006;
    }
    Slova {
        font-size: 88px;
        font-weight: 900;
    }
    Slova {
        font-size: xx-large;
        font-weight: 900;
    }
    body {
        font-size: xx-large;
        font-weight: 900;
        background-color: #000;
        color: #fff;
    }
    .a {
        font-size: xx-large;
        font-weight: 900;
    }
    .nn {
        color: #FFF;
    }
    .nn {
        color: #000;
    }
    </style>
    <style type="text/css">
    body p {
        clip: rect(200px,auto,400px,auto);
    }
    </style>
    <style type="text/css">
    sredina {
        clip: rect(400px,auto,500px,auto);
        font-size: 9px;
    }
    .sredina1 {
        clip: rect(400px,auto,100px,auto);
        font-size: 16px;
    }
    </style>
    <style type="text/css">
    Youhavetoapay {
        clip: rect(500px,auto,100px,auto);
    }
    </style>
    <style type="text/css">
    Price {
        clip: rect(500px,auto,100px,auto);
    }
    #price {
        margin-right: auto;
        margin-left: auto;
        margin-top: 500px;
    }
    </style>
    <style type="text/css">
    .price11 {
        clip: rect(500px,auto,100px,auto);
    }
    </style>
    <style type="text/css">
    #vv {
        clip: rect(1000px,auto,100px,auto);
    }
    </style>
    <style type="text/css">
    .ii {
        clip: rect(1000px,auto,auto,200px);
        margin-top: 1000px;
    }
    </style>
    <style type="text/css">
    .iijj {
        clip: rect(1000px,auto,auto,auto);
    }
    #qq {
        clip: rect(1000px,auto,auto,auto);
    }
    </style>
    <link href="ss.css" rel="stylesheet" type="text/css">
    <style type="text/css">
    kkkkkkkkkk {
        margin-top: 1000px;
    }
    </style>
    <style type="text/css">
    kkkkkkkkkkk {
        margin-top: 1000px;
    }
    </style>
    <style type="text/css">
    .hhhhhh {
        margin-top: 1000px;
    }
    </style>
    <style type="text/css">
    Slova {
        color: #000;
    }
    .Slova {
        color: #000;
    }
    body,td,th {
        color: #000;
    }
    Slova {
        color: #000;
    }
    body {
        background-color: #FFF;
        color: #000;
    }
    </style>
    <style type="text/css">
    #Echo {
        clip: rect(auto,1000px,auto,0px);
        margin-right: 1000px;
        margin-left: 0px;
    }
    </style>
    <style type="text/css">
    .echo {
        font-size: 88px;
    }
    </style>
    <body bgcolor="#000000" text="#000066">

    </h2>
    <div align =center>
    <h2>








      
      

      
      
      
      
      <span class="ii">
      <?php 


    $ending 
    strtotime($_POST['endDate']);
    $starting strtotime($_POST['startDate']);

    $numberDays floor(abs($ending -$starting) / 86400);



    echo 
    "You want reserve room number   (".$_POST["rooms"].")  from " .$_POST['startDate']. " until " .$_POST['endDate']. " in period of " .ceil($numberDays). " day(s) and ".ceil($numberDays)." night(s).";
    if(
    $_POST['rooms']=="1"){
        
    $s1=100;
    }else if (
    $_POST['rooms']=="2"){
        
    $s1=200;
    }else if(
    $_POST['rooms']=="3"){
        
    $s1=300;
    }else if (
    $_POST['rooms']=="4"){
        
    $s1=400;
    }
    $price=$numberDays*$s1;
        
     echo 
    "<div style='text-align:down 1000px'><h1> "$_SESSION['price']."</h1></div>";

             echo 
    '<br />You have to pay  € '.$price;



    if( 
    $vr2 "0" )
    {


    }

    {

        
        }
        
        
    //$_POST['brojDana']=$brojDana;


        

      



     
         
         
        


         
         
         


     

     
    ?>
      </span>
     

    <p class="nn">&nbsp;<?php echo $row_Recordset2['']; ?></p>
    <?php 

    echo "<div style='text-align:down 1000px'><h1> "$_SESSION['rooms,you,have,kids,you, have,adult']."</h1></div>";
     
    ?>
    <h3>You want[        <?php echo $_POST['rooms']; ?> ]rooms . You have [      <?php echo $_POST['kids']; ?>     ]kids. You have[      <?php echo $_POST['adult']; ?>         ]adult.<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
        
       
      <h5>&nbsp;
      </h5>
      <h5 class="Slova">&nbsp;</h5>


    $user_name = "";
    $password = "";
    $database = "";
    $server = "";



    print "";








     





    ?>


    <?php 


    $host
    =""// Host name 
    $username=""// Mysql username 
    $password=""// Mysql password 
    $db_name=""// Database name 
    $tbl_name=""// Table name 



       
    $maxRooms1 10;
        
    $maxRooms2 10;
         
    $maxRooms310;
       
       
       
         
    $maxRooms 10;
        
    $fetchQuery "SELECT rooms FROM adult
                  WHERE rooms = '$_POST[rooms]'"
    ;
        
    $fetchResult mysql_query($fetchQuery);
        
    $numberRooms mysql_num_rows($fetchResult);
            if(
    $numberRooms $maxRooms)
        
        
        
        
        
         {
                echo 
    " All rooms  of this kind are currently booked,try diffrent style of the rooms.";
           
         }
         else
            {
           
            }

    $room1 "SELECT count(*) as count FROM adult
    WHERE rows = '1' AND startDate "
    ;

    $room2 "SELECT count(*) as count FROM adult
    WHERE rows = '2' AND startDate "
    ;

    $room3 "SELECT count(*) as count FROM adult
    WHERE rows = '3' AND startDate "
    ;
            
      

    ?>
    <?php
    if ($numberRooms <= 10)

     echo 
    $row_Recordset1['ID']; ?>

    <?php
     
    if($numberRooms 11)
     
    $fetchQuery "SELECT rooms FROM adult
                  WHERE ID = '$_POST[ID]'"
    ;
        
    $fetchResult mysql_query($fetchQuery);
        
    $numberRooms mysql_num_rows($fetchResult);
          if(
    $numberRooms 11)  
     
             
     
         

     
     echo  
    "<-- Write down your ID for checkout on the front desk ."
     

      
         else if (
    $numberRooms 10)
             echo
    "";    
                


    mysql_free_result($Recordset1);
    ?>

  • #7
    Regular Coder
    Join Date
    Aug 2013
    Posts
    196
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dubz View Post
    Don't use post variables to display results, you should get the data from the database. The $_POST only works when you submit data, after that it's not there. You need to grab the information from the database and display it how you'd like to, whether in a table or something else.
    How can get exact days difference between startDate and endDate.I tried $price=$row_Recordset1['startDate']-$row_Recordset1['startDate'] / 86400; but didn't wont display $price.

    This code was working perfect on another url
    PHP Code:

    $ending 
    strtotime($_POST['endDate']);
    $starting strtotime($_POST['startDate']);

    $numberDays floor(abs($ending -$starting) / 86400);

    echo 
    "You want reserve room number   (".$_POST["rooms"].")  from " .$_POST['startDate']. " until " .$_POST['endDate']. " in period of " .ceil($numberDays). " day(s) and ".ceil($numberDays)." night(s).";
    if(
    $_POST['rooms']=="1"){
        
    $s1=100;
    }else if (
    $_POST['rooms']=="2"){
        
    $s1=200;
    }else if(
    $_POST['rooms']=="3"){
        
    $s1=300;
    }else if (
    $_POST['rooms']=="4"){
        
    $s1=400;
    }
    $price=$numberDays*$s1;
        
     echo 
    "<div style='text-align:down 1000px'><h1> "$_SESSION['price']."</h1></div>";

             echo 
    '<br />You have to pay  € '.$price;

    if( 
    $vr2 "0" )
    {


    }

    {

        }
    //$_POST['brojDana']=$brojDana; 
    But right now is not working.
    Last edited by VIPStephan; 05-19-2014 at 04:24 PM. Reason: cleaned up BB code block

  • #8
    Regular Coder
    Join Date
    Sep 2011
    Posts
    428
    Thanks
    18
    Thanked 26 Times in 26 Posts
    Read the variable names then try again, if you can't catch that then you might need to go take a nap and come back to it

  • #9
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Also, I see some things like this .... in red:

    (".$_POST["rooms"].") from " .$_POST['startDate']

    whereas, in the next variable, you're using single quotes.

    Who knows how many other places there are mis-used quotes.

  • #10
    Regular Coder
    Join Date
    Aug 2013
    Posts
    196
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    Also, I see some things like this .... in red:

    (".$_POST["rooms"].") from " .$_POST['startDate']

    whereas, in the next variable, you're using single quotes.

    Who knows how many other places there are mis-used quotes.


    I changed all single quotes in double quotes
    still have problems and this code is working in another url.

  • #11
    Regular Coder
    Join Date
    Aug 2013
    Posts
    196
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Pearl_9 View Post
    I changed all single quotes in double quotes
    still have problems and this code is working in another url.
    PHP Code:

    and this is input 
    html 


        <!--search-->
    <div class="main-search"></div>
        <form method="post" name="form1" action="<?php echo $editFormAction?>">
          <div align="center">
            <table align="center">
              <tr valign="baseline">
                <td nowrap align="right"><h5>Rooms:</h5></td>
                <td><input type="text" name="rooms" value="<?php echo $_POST['rooms']; ?>" size="32"></td>
              </tr>
              <tr valign="baseline">
                <td nowrap align="right"><h5>Adult:</h5></td>
                <td><input type="text" name="adult" value="<?php echo $_POST['adult']; ?>" size="32"></td>
              </tr>
              <tr valign="baseline">
                <td nowrap align="right"><h5>Kids:</h5></td>
                <td><input type="text" name="kids" value="<?php echo $_POST['kids']; ?>" size="32"></td>
             <tr valign="baseline">
          <td nowrap align="right"><h5>StartDate:</h5></td>
          <td><input type="text" id="startDate" name="startDate" value="<?php echo $_POST['startDate']; ?>" size="32"></td>
        </tr> </tr>
            <h5>&nbsp;</h5>
        
        <tr valign="baseline">
          <td nowrap align="right"><h5>EndDate:</h5></td>
          <td><input type="text" id="endDate" name="endDate" value="<?php echo $_POST['endDate']; ?>" size="32"></td>
        </tr>
              
              <tr valign="baseline">
                <td nowrap align="right"><h2>&nbsp;</h2></td>
                <td><input name="Submit" type="submit" id="Submit" value="Submit"></td>
              </tr>
            </table>
            <input type="hidden" name="MM_insert" value="form1">
          </div>
    </form>

  • #12
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    When you say it works with another URL, do you mean a completely different website and webhost?

  • #13
    Regular Coder
    Join Date
    Sep 2011
    Posts
    428
    Thanks
    18
    Thanked 26 Times in 26 Posts
    Quote Originally Posted by mlseim View Post
    Also, I see some things like this .... in red:

    (".$_POST["rooms"].") from " .$_POST['startDate']

    whereas, in the next variable, you're using single quotes.

    Who knows how many other places there are mis-used quotes.
    This doesn't matter, a string is a string whether it's in single or double quotes. Single quotes take the text literally while double quotes allow for input, such as variables and line breaks. Mixing them in the script may not be your liking, but it won't stop it from working if used correctly.
    For example:
    PHP Code:
    $foo 'bar';
    echo 
    "Lets go to the $foo"//Outputs: Lets go to the bar
    echo 'Lets go to the $foo'//Outputs: Lets go to the $foo 

    Now as for the form, what exactly are you trying to accomplish? What it looks like you're trying to do is keep the fields populated with what you post, at least that's what this code is doing. If you want to save the data to use later then you need to look into MySQLi (MySQL with PHP is deprecated) or something of the sort to do this for you and you'll need to learn how to both save (input) the data to the database and retrieve (select) the data back from the database. Once you have the data then it's only a matter of what you want to do with it.


  •  

    Posting Permissions

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