Closed ghost closed 8 years ago
so, just to get the thing right.... where you creating a new user, or updating the data of one?
@ricmach along with what @creptor asked, could you paste the code for the page and the queries
Good afternoon,
I send below the code from queries.php.
<?php
if(isset($_POST['submitted']) == 1){
$slug = mysqli_real_escape_string($dbc, $_POST['slug']);
$title = mysqli_real_escape_string($dbc, $_POST['title']);
$label = mysqli_real_escape_string($dbc, $_POST['label']);
$header = mysqli_real_escape_string($dbc, $_POST['header']);
$body = mysqli_real_escape_string($dbc, $_POST['body']);
if(isset($_POST['id']) != ''){
$q = "UPDATE pages SET user = $_POST[users], slug = '$slug', label = '$label', title = '$title', header = '$header', body = '$body' WHERE id = $_GET[id]";
$action = 'updated';
}else{
$q = "INSERT INTO pages (user, slug, label, title, header, body) VALUES ($_POST[users], '$slug', '$label', '$title', '$header', '$body')";
$action = 'added';
}
$r = mysqli_query($dbc, $q);
if($r){
$message = '<p>Page was '.$action.'!</p>';
}else{
$message = '<p>Page could not be '.$action.' because:'.mysqli_error($dbc);
$message .= '<p>'.$q.'</p>';
}
}
?>
And next is the setup.php.
<?php
/*Setup File:
*/
#Database Conection here
//$dbc = mysqli_connect('localhost', 'dev', 'thepassword1', 'sipre') OR die('Could not connect because:'.mysqli_connect_error());
error_reporting(0);
#Functions:
include ('functions/data.php');
include ('functions/sandbox.php');
#Page Settings:
$debug = data_status($dbc, 'debug-status');
if(isset($_GET['page'])){
$page_id = $_GET['page'];
}else{
$page_id = 1;
}
#User Data:
$user = data_user($dbc, $_SESSION['username']);
#Page Setup:
if(isset($_GET['id'])){$opened = data_page($dbc, $_GET['id']);}
include ('config/queries.php');
$page = data_page($dbc, $page_id);
$site_title = 'Plataforma de E-Commerce';
$page_title = 'Home';
?>
title, slug and other atributes are for pages table.
try this in that line:
if(isset($_POST['id'])&&is_numeric($_POST['id'])){
sry for the other comment, my mistake
A no WAIT You used get, and it's $_POST['id'] in the query :smile:
@creptor if(isset($_POST['id'])&&is_numeric($_POST['id'])){ works perfectly.
Again thank you for your support.
Thank you again @creptor !!
First Thank you for your support in other issue @thedigicraft and @creptor.
I test now the Update/Insert script and see that when I run the script with condition if(isset($_POST['id']) != '') the server interpret this as the $_POST['id'] is with a value but not run the else statement so I can't never do the insert, but if I change the if statement to if(isset($_POST['id']) != ' ') it runs in the oposite way the server understand that this is empty and never update and the error message is the following:
Sorry for bothering you but my code is like a boat with a hole when I fix in a place opens up another hole just like that.
Thank you for your support.