Jump to content

Dynamic page problem


esoteric

Recommended Posts

I cannot understand the problem with this script, im trying to have a invoice page that is updated with the information from my sql table depending on what the user types into a little form.

 

My http form is just;

<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tr>
                          <td width="52%" align="center">Order Number</td>
                          <td width="48%"><input name="order" type="text" id="order" size="20" /></td>
                        </tr>
                        <tr>
                          <td><p> </p></td>
                          <td><p>
                              <input name="button" type="submit" id="button" value="Submit" />
                            </p></td>
                        </tr>
                      </table>

 

My php page is;

<?php include 'dbc.php'; page_protect();?>
<?php

$order 	= $_POST['order'];

mysql_connect("xxx", "xxx", "xxx") or die( "Unable to connect to database");
mysql_select_db("membership") or die( "Unable to select database");
$result = mysql_query("SELECT * FROM orderTable WHERE orderNum = '$order'");

$username 	= "test";
$password 	= "test";

if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {

?>
<h1>Login</h1>

<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <p><label for="txtUsername">Username:</label>
    <br /><input type="text" title="Enter your Username" name="txtUsername" /></p>
    <p><label for="txtpassword">Password:</label>
    <br /><input type="password" title="Enter your password" name="txtPassword" /></p>
    <p><input type="submit" name="Submit" value="Login" /></p>
</form>

<?php
}
else {
?>



<table width="50%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="29%">First Name</td>
    <td width="71%"><?php echo $result['firstName']; ?></td>
  </tr>
  <tr>
    <td>Lastname</td>
    <td><?php echo $result['lastName']; ?></td>
  </tr>
    <tr>
    <td>Order Number</td>
    <td><?php echo $result['orderNum']; ?></td>
  </tr>
    <tr>
    <td>Order Date</td>
    <td><?php echo $result['orderDate']; ?></td>
  </tr>
    <tr>
    <td>Order</td>
    <td><?php echo $result['strMessageBody']; ?></td>
  </tr>
    <tr>
    <td>Total</td>
    <td><?php echo $result['total']; ?></td>
  </tr>
  
</table>


<?php
}
?> 

 

It just doesn't display anything! Any help is much appreciated.

Thank you.

 

 

Link to comment
https://forums.phpfreaks.com/topic/244676-dynamic-page-problem/
Share on other sites

  • 3 months later...

Please, Follow These three step and solve your error:

 

- You can make empty files named index.php, page1.php, page2.php, page3.php. Now add content.

- index.php - this file contains alone the layout. The agreeable space is empty. Remember, this is an absolute html file, which use it compulsory to basic HTML structure(<html> <head> </head> <body> </body> </html>) and what comes in between.

- page1.php, page2.php, page3.php - these 3 files contain only the content. No layout. Just throw on some headings, paragraphs of text and images here.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.