Need help with my php and mysql pages

I have a project that I’m working on and having trouble fixing it. So i have a dog walking website and i have a database called ‘Dogsmart’ in that database are three tables one for users login, the other for ‘services’ and the main one for ‘bookings’.

So far i have a login working only for the users with a session and somewhat for admin but need to add a session for admin. I have manage to get the a table to be viewed on the bookings page but having trouble getting add booking and edit booking working

wanted to know if you could help me.

Thanks

–new_booking.php

[php]

New Booking

New Bookings

<?php // connect to the database include('connect.php'); if(isset($_POST['submit'])) { $name=mysql_real_escape_string($_POST['name']); $service=mysql_real_escape_string($_POST['service']); $date=mysql_real_escape_string($_POST['date']); $time=mysql_real_escape_string($_POST['time']); $query1=mysql_query("INSERT INTO bookings values(users.username, services.service,'$date','$time')"); //echo "insert into bookings values('','$name','$service','$date','$time')"; if($query1) { header("location:booking_view.php"); } } $query = mysqli_query("SELECT username FROM users"); ?>



Name: *

<?php while ($row = mysqli_fetch_array($query)) { echo "'".$row['1']."'"; } ?>



Service: *

Dog Walking (Solo) Dog Walking (Group) Dog Grooming (Large Dogs) Dog Grooming (Medium Dogs) Dog Grooming (Small Dogs) House Sitting

Date: *

Time: *

* required

[/php]

—edit_booking.php
[php]

Edit Booking

Edit Bookings

<?php /*if ($error != '') { echo "
" . $error . "
"; } */?> <?php // connect to the database include('connect.php'); if(isset($_GET['id_bookings'])) { $id_bookings=$_GET['id_bookings']; if(isset($_POST['submit'])) { $service=$_POST['service']; $date=$_POST['date']; $time=$_POST['time']; $query1 = mysqli_query("SELECT * FROM bookings WHERE id_bookings='$id_bookings'"); $query2 = mysqli_fetch_array($query1); $query3 = mysqli_query("UPDATE bookings SET service='$service', date='$date', time='$time' WHERE id_bookings='$id_bookings'"); if($query3) { header('location:bookings_view.php'); } } ?>
<?php if ($id_bookings != '') { ?>

ID: <?php echo $id_bookings; ?>

<?php } ?>

Service: *

Dog Walking (Solo) Dog Walking (Group) Dog Grooming (Large Dogs) Dog Grooming (Medium Dogs) Dog Grooming (Small Dogs) House Sitting

Date: *

Time: *

* Required


<?php } ?>

[/php]

Thanks

First and foremost, don’t drop variables into SQL statements, it is bad and very dangerous.

Everything is quite basic, but it doesn’t convey what you are trying to do or asked about.

Unfortunately for you, all of this code is no good. It is obsolete, insecure and has been completely removed from Php. You need to use PDO with prepared statements. Study this tutorial. https://phpdelusions.net/pdo

Sponsor our Newsletter | Privacy Policy | Terms of Service