Jump to content

torpedo91

New Members
  • Posts

    8
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

torpedo91's Achievements

Member

Member (2/5)

0

Reputation

  1. I have this (display_items.php) script which should not be accessed directly . user will be directed to a login page, the login checked by a check_login.php file then successful authentication will direct the user to the display_items.php page. it works perfectly on windows server but not on linux. the display_items.php script can be accessed directly on the linux server. It may have something to do with sessions but i cannot pin point the issue at the moment . i have attaced the php script files. Grateful if someone could point me in the right direction check_login.txt display_items.txt login.txt
  2. i am in the process of creating an auction site. However the images do not show , just the placeholder. Can anyone indicate where I have gone wrong ? i am using this script to enter the items into the Database html> <head><title></title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <?php echo "<img src='auction_logo.png' id='logo'/>"; echo "<br>"; echo "<form class='add_item_form' action='check_item.php' method='POST' enctype='multipart/form-data'>"; if(isset($_GET["item"])) { if($_GET["item"]=="duplicate") { echo "<h4>Already entered this item</h4>"; echo "<br>"; echo "<h4>Please try again</h4>"; } else if($_GET["item"]=="successful") { echo "<h4>Successfully added an item!</h4>"; } } else { echo "<h4>Please add an item</h4>"; } echo "<label for='item_name' class='label'>Item Name:</label>"; echo "<input class='text' type='text' name='item_name'/>"; echo "<br>"; echo "<label for='item_description' class='label'>Item Description:</label>"; echo "<input class='text' type='text' name='item_description'>"; echo "<br>"; echo "<label for='endtime' class='label'> Ending Bid Time: </label>"; echo "<input class='text' type='text' name='endtime'>"; echo "<br>"; echo "<label for='item_pic' class='label'>Item Picture: </label>"; echo "<input class='text' type='file' value='item_pic' name='item_pic'>"; echo "<br>"; echo "<input class='submit' type='submit' value='Add Item'/>"; echo "</form>"; ?> </body> </html> This script displays the items : <html> <head><title></title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <?php session_start(); if(!isset($_SESSION["username"])) { header("Location:login.php"); } else { $DBHOST = "localhost"; $DBUSER = "root"; $DBPWD = ""; $DBNAME = "customs_auction"; $conn = new mysqli($DBHOST, $DBUSER, $DBPWD, $DBNAME); if($conn->connect_error) { die("Connection failed!".$conn->connect_error); } echo "<img src='auction_logo.png' id='logo'/>"; echo "<a href='logout.php' class='logout button'>Logout </a>"; $statement = "SELECT * FROM item"; $result = $conn->query($statement); while($row = $result->fetch_assoc()) { $iid = $row["item_id"]; $iname= $row["item_name"]; $ipic = $row["item_pic"]; $icurrentp = $row["current_bid"]; $iimg = "item/"; $iimg = $iimg.$row["item_pic"]; $link = "item_details.php?item_id="; $item_details = $link.$iid; echo "<div class='item'>"; echo "<div class='item_row'>Item Id: $iid</div>"; echo "<div class='item_row'>Item Name: $iname</div>"; echo "<img class='item_img' src='$iimg' alt='image'>"; echo "<div class='item_row'>Current Bid: $$icurrentp</div>"; echo "<div class='item_row' ><a class='link' href='$item_details'>Item Details</a></div>"; echo "</div>"; }/*display all the items on screen*/ $conn->close(); }/*prevent direct access by user*/ ?> </body> </html>
  3. checked the database that i created in phpmyadmin. no rows added.
  4. Good day all , I am in the processes of creating a add buyer page for an auction site. However , the rows are not updating when i add a new buyer. Below is the code i have written . This is the add buyer form page : <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php echo "<img id='logo' src='auction.png'/>"; echo "<br>"; echo "<form class='add_buyer_form' action='check_buyer.php' method='POST'>"; if (isset($_GET["buyer"])) { if($_GET["buyer"] == "successful") { echo"<h4>Successfully added user!</h4>"; } else if ($_GET["buyer"] == "duplicate") echo"<h4? BUyer already exists. Please enter another username and password<h4>"; } else { echo "<h4>Please Add the buyers username and password</h4>"; } echo "<label class='label' for='username'>Username:</label>"; echo "<input class='text' type='text' name='username' placeholder='username'>"; echo "<br>"; echo "<label class='label' for='password'>Password:</label>"; echo "<input class='password' type='password' name='password' placeholder='Password'>"; echo "<input class='submit' type='submit' value='Add Buyer'>"; echo"</form>"; ?> </body> </html> This is the check buyer form page : <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php if (!empty($POST["username"]) && !empty($_POST["password"])) { $DBHOST = "localhost"; $DBUSER = "tim"; $DBPWD = "nineteen1985"; $DBNAME = "customs_auction"; $conn = new mysqli($DBHOST, $DBUSER, $DBPWD, $DBNAME); if ($conn->connect_error) { die("connection failed:" .$conn->connect_error); } $username = $_POST["username"]; $password = $_POST["password"]; $hashed = password_hash($password, PASSWORD_DEFAULT); $statement = "SELECT * FROM buyer WHERE username=?"; $stmt = $conn->prepare($statement); $stmt->bind_param("s", $username); $stmt->execute; $result = $stmt->get_result(); if ($result->num_rows>=1) { $value = "duplicate"; header("Location: add_buyer.php?buyer=$value"); } else { $statement = "INSERT INTO buyer(username,password) VALUES(?, ?)"; $stmt = $conn->prepare($statement); $stmt->bind_param("ss", $username, $hashed); $stmt->execute; $value = "successful"; header("Location: add_buyer.php?buyer=$value"); } $conn->close(); } else { header("Location: add_buyer.php"); } ?> </body> </html>
  5. Im developing with PHP. Was wondering what is the connection string for php-MSSql
  6. 1)im trying to save basic user login information like firstname, lastame , age etc to MSSQl database .. was wondering if a connection string was required to do this. IS it different from saving to a MYSQL database?
  7. Hello all i am fairly new to php . Was wondering if anyone could point me to some good practice projects or links where i can find some good ones/
×
×
  • 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.