Object not Found 404 Error [duplicate] - php

This question already has answers here:
Object Not Found error for simple php script
(4 answers)
Closed 9 years ago.
This code returns me a 404 Object Not Found error that I could not solve by modifying the code. And I don't know whether it's a code problem or a localhost problem. I need this to be running for my Final Year Project. Please help. Thanks a lot guys.
<?php
session_start();
require "dbc.php";
echo "<center>";
echo "<img src='web_header.jpg'/>";
echo "</center>";
if($_SESSION['admin_username'])
{
echo "Hello : ".$_SESSION['admin_username'];
echo "<p><a href ='admin_panel.php'>Admin Main</a> || <a href='manage_patients.php'>Manage Patients</a> || <a href ='manage_doctor.php'>Manage Doctors</a> || <a href ='mail_form.php'>Send Email</a> || <a href='logout.php'>Logout</a> ";
echo "<title>Manage Patients</title>";
echo "<h2>Manage Patients</h2>";
$query = mysql_query("SELECT * FROM users");
$numrows = mysql_num_rows($query);
if ($numrows != 0)
{
echo "<table width='1285' height='102' border='1'>";
echo "<tr><th>ID</th><th>Name</th><th>IC Number</th><th>Address</th><th>Mobile Number</th><th>E-mail Address</th><th>Doctor ID</th></tr>";
while ($rows = mysql_fetch_assoc($query))
{
echo "<tr>";
echo "<td width='57' height='33'>";
echo "<center>";
echo $rows['id'];
echo "</center>";
echo "</td>";
echo "<td width='173'>";
echo $rows['name'];
echo "</td>";
echo "<td width='113'>";
echo "<center>";
echo $rows['icnum'];
echo "</center>";
echo "</td>";
echo "<td width='622'>";
echo $rows['address'];
echo "</td>";
echo "<td width='110'>";
echo "<center>";
echo $rows['mobile'];
echo "</center>";
echo "</td>";
echo "<td width='170'>";
echo "<center>";
echo $rows['email'];
echo "</center>";
echo "</td>";
echo "<td width='90'>";
echo "<center>";
echo $rows['docID'];
echo "</center>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
echo"<br>";
echo"</br>";
echo "<form action = 'manage_patients.php method=POST'>";
echo "<p>Assign Doctor ID : ";
echo "<input type='text' name='assign_id' value='Insert Doctor ID Here'>";
echo " for Patient ID : ";
echo "<input type='text' name='id' value='Insert Patient ID Here'></p>";
echo "<input type= 'submit' name='submit' value='Assign Now'>";
echo "</form>";
if (isset($_POST['submit']))
{
require "dbc.php";
$name = mysql_real_escape_string($_POST['assign_id']);
$id = mysql_real_escape_string($_POST['id']);
$query = mysql_query("UPDATE users SET docID='$assign_id' WHERE id='$id'");
echo "Doctor ID Successfully Assigned for Patient ID : $name ";
echo "<p>Refresh page to view changes.</p>";
}
}
}
else
{
header("location:index.html");
}
?>

change this
<form action = 'manage_patients.php method=POST'>
to
<form action = 'manage_patients.php' method='POST'>

If you are getting a 404 Error, it means that the page could not be found. So it is most likely not a problem with your code (that would give you a 500 Server Error). Instead you most likely have used the wrong URL.

<form action = 'manage_patients.php method=POST'>
I find this line of yours a bit suspiscious

Related

Stop button to repet in loop

Is there any way to stop a button from submit button to stop looping in while loop?
it just looks terrible to have like 15 submit buttons insted of 1. whitout moving it from the from
$sql = "SELECT * FROM `bestalning` WHERE lev=0
ORDER BY tid";
$result = mysqli_query($conn, $sql) or die(mysqli_error($conn));
echo "<div class='continer bg-vit table-rsponsive-sm '>";
echo "<table class='table'>";
echo "<thead class='thead-dark'>";
echo "<tr><th>Lev</th>";
echo "<th> </th>";
echo "<th>Artikelnr</th>";
echo "<th>Antal</th>";
echo "<th>Singnatur</th>";
echo "<th>Önskad ankomst</th>";
echo "<th>Skickad</th>";
echo "</tr></thead><tbody>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<form method='POST' action='ID_change.php'>";
echo "<td><input style='margin-right:5px;' name='levJA' type='checkbox' value='1'></td>";
echo "<td><input style='margin-right:5px;' name='RowID' type='hidden' value='".$row['ID']."'></td>";
echo "<td>".$row['artikelnr']."</td>";
echo "<td>".$row['antal']."</td>";
echo "<td>".$row['ovrigt']."</td>";
echo "<td>".$row['Tid']."</td>";
echo "<td>".$row['date']."</td>";
echo "<input class='btn btn-dark m-1' type='submit' value='submit'>;
echo "</form>";
echo "</tr>";
}
echo "</tbody></table>";
echo "</div>";
mysqli_close($conn);

I want to know how to get the selected data on another webpage using PHP

I have use loop to show limited data and each loop i have button to select it.
I have a syntax error in my view.php i dont know what to put in that query
How do i select a row in index.php to view more details in view.php. I tried giving it a name in the echo $rows; loop but i got syntax error too.
This is my code in index.php
<?php
$sqlQuery = mysql_query("SELECT fname FROM info");
while ($rows = mysql_fetch_array($sqlQuery)){
echo $rows['fname'];
echo "<input type='submit' value='Show more info' name='submit' class='btn btn-info'>";
}
?>
-----------------------end code for index------------------------------
this is my code in view
<?php
$sqlQuery = mysql_query("SELECT * FROM info WHERE fname=$_POST['fname']");
echo "<table border='1' width='50%'>";
echo "<tr>";
echo "<td>First Name</td>";
echo "<td>last Name</td>";
echo "<td>Age Name</td>";
echo "</tr>";
while ($rows = mysql_fetch_array($sqlQuery)){
echo "<tr>";
echo "<td>";
echo $rows['fname'];
echo "</td>";
echo "<td>";
echo $rows['lname'];
echo "</td>";
echo "<td>";
echo $rows['age'];
echo "</td>";
echo "</tr>";
}
echo "</table>";
?>
-------------------------------end code for view--------------------
<form method="POST" action="view.php">
<?php
$sqlQuery = mysql_query("SELECT fname FROM info");
while ($rows = mysql_fetch_array($sqlQuery)){
echo "<input type='text' value='".$rows['fname']."' name='fname'>";
echo "<input type='submit' value='Show more info' name='submit' class='btn btn-info'>";
}
?>
</form>
Try this in view.php
echo $_POST['fname'];
$query = "SELECT * FROM info WHERE fname LIKE ".$_POST['fname']."";
echo $query;
check what output are you getting

PHP Database form CSS

I have the following code:
<?php
require "dbconn.php";
$register="SELECT * from register WHERE username = '". $_SESSION['username']."'";
$re = $connect->query($register);
$numrow = $re->num_rows;
echo "<table>";
echo "<tr>";
echo"<th>Username</th>";
echo"<th>Forename</th>";
echo"<th>Surname</th>";
echo"<th>Course</th>";
echo"<th>Subject</th>";
echo"<th>Level</th>";
echo"<th>Date</th>";
echo"<th>Time</th>";
echo"</tr>";
$count = 0;
while ($count < $numrow)
{
$row = $re->fetch_assoc();
extract($row);
echo "<tr>";
echo "<td>";
echo $username;
echo "</td>";
echo "<td>";
echo $firstName;
echo "</td>";
echo "<td>";
echo $surname;
echo "</td>";
echo "<td>";
echo $course;
echo "</td>";
echo "<td>";
echo $subject;
echo "</td>";
echo "<td>";
echo $level;
echo "</td>";
echo "<td>";
echo $date;
echo "</td>";
echo "<td>";
echo $time;
echo "</td>";
echo "</tr>";
$count = $count + 1;
}
?>
It shows the records from the database as a form. I have the following button:
<FORM METHOD="LINK" ACTION="register.php">
<INPUT TYPE="submit" VALUE="Go back to register"></INPUT></form>
No matter what DIV I put the button in, or what CSS I give it. The button always stays ABOVE the form from the database and I cannot get it below the table.
Any ideas?
Firstly, you did not close your table with a </table> tag; it's important that you do.
Then there's METHOD="LINK" which doesn't exist and isn't a valid method.
You either want to use method="post" or method="get".
See this answer on Stack about it:
https://stackoverflow.com/a/11582427/

Displaying information from a table then showing related information from another table

Hello I have 2 tables.
One is a table (nameinfo) that consists of contact information (account, name, email, address, city, state, zip, tags)
Table Two is an events tables (events) (email, event_type, event_name, date, keywords)
Here is what I am trying to do...
I would like to show a list of all the events that the person went to based on the matching email address. I would like to return the results like this...
nameinfo person 1
events person 1 went to
nameinfo person 2
events person 2 went to
nameinfo person 3
events person 3 went to
$query = mysql_query("SELECT * FROM nameinfo WHERE account='$a'");
while($row = mysql_fetch_array($query))
{
$i++;
echo "<div>";
echo "<table><tr style='font-weight:bold;color:green;font-size:9pt;text-align:left;'><td style='text-align:left;'
>";
echo "<button class='toggles' id='".$i."'/>"; echo $row['fullname']."</button>";
echo "</td>";
echo "<td >";
echo $row['target'];
echo "</td><td >";
echo $row['lname'];
echo "</td>";
echo "<td >";
echo $row['fname'];
echo "</td><td >";
echo $row['title'];
echo "</td>";
echo "<td >";
echo $row['company'];
echo "</td><td >";
echo $row['address'];
echo "</td>";
echo "<td >";
echo $row['address2'];
echo "</td><td>";
echo $row['city'];
echo "</td>";
echo "<td>";
echo $row['state'];
echo "</td><td>";
echo $row['zip'];
echo "</td>";
echo "<td>";
echo $row['email'];
echo "</td><td>";
echo $row['officenum'];
echo "</td>";
echo "<td>";
echo $row['cellnum'];
echo "</td>";
echo "<td>";
echo $row['date'];
echo "</td><td>";
echo $row['rep'];
echo "</td></tr></table></div>";
echo "<div style='width:100%;background:#000;color:#fff;display:none;' id='show-".$i."'>";
**echo THIS IS WHERE I WOULD LIKE TO PUT THE EVENT INFORMATION BUT HAVE NO IDEA HOW TO DO IT.;**
echo "</div>";
}
<script>
$("button.toggles").click(function() {
var value = $(this).attr('id');
$("#show-" + value).toggle();
});
</script>
Thank you for any assistance.
Run another query inside the loop. Here I am calling a function to do the job:
$i=0;
$link = ""\\your database connection
$query = mysql_query("SELECT * FROM nameinfo WHERE account='$a'");
while($row = mysql_fetch_array($query)){
$i++;
echo "<div>";
echo "<table><tr style='font-weight:bold;color:green;font-size:9pt;text-align:left;'><td style='text-align:left;'>";
echo "<button class='toggles' id='".$i."'/>"; echo $row['fullname']."</button>";
echo "</td>";
echo "<td >";
echo $row['target'];
echo "</td><td >";
echo $row['lname'];
echo "</td>";
echo "<td >";
echo $row['fname'];
echo "</td><td >";
echo $row['title'];
echo "</td>";
echo "<td >";
echo $row['company'];
echo "</td><td >";
echo $row['address'];
echo "</td>";
echo "<td >";
echo $row['address2'];
echo "</td><td>";
echo $row['city'];
echo "</td>";
echo "<td>";
echo $row['state'];
echo "</td><td>";
echo $row['zip'];
echo "</td>";
echo "<td>";
echo $row['email'];
echo "</td><td>";
echo $row['officenum'];
echo "</td>";
echo "<td>";
echo $row['cellnum'];
echo "</td>";
echo "<td>";
echo $row['date'];
echo "</td><td>";
echo $row['rep'];
echo "</td></tr></table></div>";
echo "<div style='width:100%;background:#000;color:#fff;display:none;' id='show-".$i."'>";
getEvent($row['email']);//Pass the email to the function here
echo "</div>";
}
function getEvent($email){
global $link;
$evant = "";
$query = mysql_query("SELECT * FROM events WHERE email='$email'", $link);
while($row = mysql_fetch_array($query)){
$event = $event . $row["event_name"] . "<br />";
//Format this however you wish to format
}
return $event;
}
<script>
$("button.toggles").click(function() {
var value = $(this).attr('id');
$("#show-" + value).toggle();
});
</script>

PHP postback on submit

I have a question on php postback
My code is :
<?php
if(isset($_POST["Delete"]))
{
echo "DELETE";
}
if(isset($_POST["Modifier"]))
{
echo "Modifier";
}
if(!empty($_SESSION["Status"]))
{
if($_SESSION["Status"] == "u")
{
header("Location: Index.php?Action=Acceuil");
}
if($_SESSION["Status"] == "a")
{
$Connection = mysql_connect("localhost","root") or die(mysql_error());
mysql_select_db("tpw34") or die("Nope.");
$query = "Select * From Products";
$result = mysql_query($query);
While($ligne = mysql_fetch_assoc($result))
{
//Index.php?Action=AdminDeleteProduct&Delete=".$ligne["ProductID"]."
echo "<form method='POST' Action='#'>";
echo "<table border='1'>";
echo "<tr>";
echo "<td colspan='2'><center><img width='250' height='250' src='".$ligne["Image"]."'/></center></td>";
echo "</tr>";
echo "<tr>";
echo "<th>Nom du produit :</th>";
echo "<td>".$ligne["ProductName"]."</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Prix :</th>";
echo "<td>".$ligne["Prix"]."</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Description :</th>";
echo "<td>".$ligne["Description"]."</td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan='2'h><input type='Submit' value='Delete' name='Delete'/><input type='Submit' value='Modifier' name='Modifier'/></td>";
echo "</tr>";
echo "</table>";
echo "<br>";
echo "</form>";
}
}
}
?>
My Question is : I want to get the ProductID of the item ( in the table ) to be in the $_POST["Delete"] and $_POST["Modifier"] but i dont wanna change the text on the button. I want to keep DELETE and MODIFIER. I have read many things on the web but i dont find the correct answer.
Include a hidden form value for ProductID. Then you can retrieve the value in $_POST['ProductID']
echo "<input type=hidden name='ProductID' value='" . $ligne["ProductID"] . "'>";
You could work with sessions, where you can temporarily save your information.
Sessions
Or like Tim Dearborn suggested, use a hidden input to send it with the next form submit.

Categories