Im working on a site, writing in php, with minimal js and css.
It works okay on local host, but having problems with submit buttons when the site is uploaded to the live server.
My site has a few databases
On the live server, the submit button is not returning to the original page, but it is submitting the users inputed data to the database.
The basic structure of my site ;
index.php
about.php
[includes] header.php, footer.php, menu.php
[crud] index.php, create.php
[core] databased.php
In ‘about.php’ I insert a link to ‘index.php’ in a folder named 'crud ’
<?php include 'crud/index.php';?>This index.php page initially displays a database of names, email, mobile. There is a create button to enter new customers details, which calls the create.php file
<p>
<a href="crud/create.php" class="btn btn-success">Create</a>
</p>
When you click on the Create button a standalone page is displayed without the standard header and footer
Here you enter new customers details, there is also a create button here, and on the local host when I press this button,
it returns me to the about.php page with the new data visable in the about.php page
So on the live site,
Im on the about page, click on create,
takes me to
websiteaddress/crud/create.php
enter data click on second create button
but it just stays on this page…
here is the code I fear could be the problem
in the create.php file
// insert data
if ($valid) {
$pdo = databased::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO customers (name,email,mobile) values(?, ?, ?)";
$q = $pdo->prepare($sql);
$q->execute(array($name,$email,$mobile));
databased::disconnect();
header("Location: ../about.php");
I think the issue could be the header, as on localhost this directory Location: …/about.php works, but maybe it needs to be more specified on a liver server?
When Im on the create page
crud/create.php
and I click the create button
the data is added to the database on the live server, but this action should also return me to the about page
about.php .but it doesnt it just seems to hang and get stuck on crud/create.php but every time you click the create button as the page doesnt refresh the data you entered is still on the form, and it is added as a duplicate.
Many thanks if anyone can help