this is probaly an easy one, but I just cant seem to figure it out. I've tried googling for this aswell, but without any luck to my particular problem...
What I want, is that the radio selection gets remembered two times (kinda), it remembers after the first time I click submit. But when I click submit again on my next page, it wont remember the value.
Well, I want all the information stored in my database pretty much..
Thanks!
EDIT 1: Oh yeah, the thing that does not go into my database is "valgt_skap" or in other words "radios", everthing else works fine.
Bokssvar.php
<html>
<head>
<link rel="stylesheet" type="text/css" href="style2.css?<?php echo time(); ?>" />
<title>Registrering</title>
</head>
<body>
<?php
if(isset($_SESSION['boxfeil'])) echo $_SESSION['boxfeil'];
unset($_SESSION['boxfeil']);
?>
<form action="bestilt.php" method="post" name="inputform_Field">
<table id="valgt_skap_tabell" class="bokssvartabell">
<tr>
<td>Valgt skap</td>
</tr>
<tr>
<td>
<input class="bokssvarskjema" type="text" name="valgt_skap" disabled value= <?php
if(isset(($_POST['radios']))){
echo ($_POST['radios']);
} else {
header('location: index.php');
} ?>>
</td>
</tr>
</table>
<table id="opplysninger_tabell" class="bokssvartabell">
<tr>
<td>Fornavn:</td>
<td>Etternavn:</td>
<td>Telefon:</td>
<td>E-post:</td>
<td>Elev Nummer:</td>
</tr>
<tr>
<td><input type="text" name="Fornavn_nm" id="fornavn_check"></td>
<td><input type="text" name="Etternavn_nm" id="etternavn_check"></td>
<td><input type="text" name="Telefon_nm" id="telefon_check" maxlength=8></td>
<td><input type="text" name="E-post_nm" id="epost_check"></td>
<td><input type="text" name="Elevnummer_nm" id="elevnr_check"></td>
</tr>
</table>
<div style="text-align:center;">
<button id="bestill_skap" type="submit" name="bestill_Skap">Bestill skap</button>
</div>
</form>
</body>
bestilt.php
<?php
require 'connectdb.php';
$inputFornavn_check = $_POST['Fornavn_nm'];
$inputEtternavn_check = $_POST['Etternavn_nm'];
$inputTelefon_check = $_POST['Telefon_nm'];
$inputEpost_check = $_POST['E-post_nm'];
$inputElevnr_check = $_POST['Elevnummer_nm'];
$inputSkap_check = $_POST['valgt_skap'];
$insertInfo_query = "INSERT INTO elever (Fornavn, Etternavn, Telefon, Epost, ElevNr, Skap)
VALUES ('$inputFornavn_check' , '$inputEtternavn_check' , '$inputTelefon_check' , '$inputEpost_check' , '$inputElevnr_check' , '$inputSkap_check')";
$connect_DB->query($insertInfo_query);
?>
Try using sessions to store the value. First use session_start(), then store in $_session['fieldname']=value. Then you can use it in the preceding pages.
On the second page, receive the value and put it on a hidden form element.
<form>
...
<input type="hidden" name="valgt_skap" value="$radioValue">
...
</form>
This element is not shown on the page, although it's present and submited with the form.
Related
I am learning basic php since September 2015, and I have to create a website with a fully functioning php update code.
What I have right now is a news page with 3 rows that have to be updated in an administration panel with a submit button for every field (date, title and content), so there are 3 forms for 3 news articles.
[http://i.imgur.com/zFhiDR8.png] picture showing the fields.
So everytime a new row gets created (even though there will always be 3), a new form appears in the administration panel.
Now, the problem that I have is that only the last field gets updated.
For example, I type information in all 3 forms, but only the last form gets the updated information shown on the news page when pressing the submit button according to the corresponding form. The updated information is also not getting added in the database.
If I type info in the first content field (inhoud) and press update, it will only check if the last form is updated.
Thinking about it, this would mean that my code only checks if the last id of the database, right?
For testing, I added a new row in the database with an auto-incrementing id of 4. And the result is that only the fourth id is checked for updating.
It also says in my error checker:
"NO RECORDS UPDATED ... ... ... WHERE ID=9"
This is all the information I could think of to put in here.
This is my php code:
<?php
session_start();
if(!isset($_SESSION['gebruiker'])){
header ("Location: admin_login.php");
}
else{
require_once 'db_config.php';
$query = "
SELECT
*
FROM
gip_home_nieuws";
$result = mysql_query($query);
if(!$res = mysql_query($sql))
{
trigger_error(mysql_error().'<br />In query: '.$sql);
}
elseif(mysql_num_rows($res) == 0)
{
echo 'Geen resultaten gevonden';
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Pagina's updaten</title>
<link href="admin_page1_css.css" rel="stylesheet" type="text/css">
</style>
</head>
<body>
<div id="container">
<div id="cont_header">
<div id="header">
<div id="header_logo"><img src="images/logo.png" width="200" height="110"></div>
<div id="header_slogan">We secure your future, the easy way</div>
<div id="knop_cont">
<div class="navigatie_knop" id="knop_nieuws">Nieuws</div>
<div class="navigatie_knop" id="knop_overons">Over ons</div>
<div class="navigatie_knop" id="knop_producten">Producten</div>
<div class="navigatie_knop" id="knop_winkel">Winkel</div>
<div class="navigatie_knop" id="knop_contact">Contact</div>
<div class="navigatie_knop" id="knop_uitloggen">Uitloggen</div>
</div>
</div>
</div>
<div id="divider1"></div>
<div id="cont_inhoud">
<div id="contact1">
<div class="contact_titel id="contact1_t>Administratie</div>
<div id="contact1_c">
<form method="post" action="<?php $_PHP_SELF ?>">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<?php
while($row = mysql_fetch_array($result))
{
$id = $row['id'];
$nieuws_date = $row['nieuws_date'];
$nieuws_titel = $row['nieuws_titel'];
$nieuws_content = $row['nieuws_content'];
?>
<td width="100"></td>
</tr>
<tr>
<td width="100">id</td>
<td><input class="input1" name="form_id" type="text" value="<?=$id?>"></td>
</tr>
<tr>
<td width="100">Datum</td>
<td><input class="input1" name="form_date" type="text" value="<?=$nieuws_date?>"></td>
</tr>
<tr>
<td width="100">Titel</td>
<td><input class="input2" name="form_titel" type="text" value="<?=$nieuws_titel?>"></td>
</tr>
<tr>
<td width="100">Inhoud</td>
<td><textarea class="input3" name="form_content" type="text"><?=$nieuws_content?></textarea></td>
</tr>
<tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td width="100"> </td>
<td>
<p><input type="submit" name="updaten" value="gegevens updaten"/>
<?php } ?></p>
</td>
</tr>
</table>
</form>
<?php
if(isset($_POST[updaten]))
{
$id2 = $_POST['form_id'];
$nieuws_date2 = $_POST['form_date'];
$nieuws_titel2 = $_POST['form_titel'];
$nieuws_content2 = $_POST['form_content'];
$sql = "
UPDATE
gip_home_nieuws
SET
nieuws_date = '".$nieuws_date2."',
nieuws_titel = '".$nieuws_titel2."',
nieuws_content = '".$nieuws_content2."'
WHERE
id=$id2
";
}
if(!$res = mysql_query($sql)) {
trigger_error(mysql_error().'<br />In query: '.$sql);
}
elseif(mysql_affected_rows() == 0) {
echo 'Geen records gegwijzigd. <br />Query: '.$sql;
echo"<a href=\"index.php\">Terug</a";
}
else
{
echo 'Update was succesvol!';
echo"<a href=\"index.php\"<br><br>>Terug</a";
}
?>
</div>
</div>
</div>
<div id="divider2"></div>
<div id="footer">
<div id="cont_footer">
<div id="footer_info">© Belgian Space Industries 2016</div>
</div>
</div>
</div>
<?php } ?>
</body>
</html>
I would really appreciate some help!
EDIT: seeing some posts with comments saying I shouldn't use mysql_* functions, I was teached to use MYSQL_* functions.
So sorry if there is confusion about this, but I can't really do something about this!
If you run this code and fill in each text input what happens when you submit the form?
<?php
var_dump($_POST)
?>
<form method="POST">
<input type="text" name="foo">
<input type="text" name="foo">
<input type="text" name="foo">
<input type="submit">
</form>
As all three of those foo fields above share the same name, when you POST, only one of the foo input's value will be available (it will clobber the other two).
You need to create three separate forms by creating each form inside your loop. Currently you have one form (your form html tags surround the loop).
You want something more akin to this:
<?php for($i=0; $i<3; $i++ ) { ?>
<form method="POST">
<table>
<tr>
<td>
Foo:
</td>
<td>
<input type="text" name="foo">
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit">
</td>
</tr>
</table>
</form>
<?php } ?>
Swap out the for for your while.
You should at least escape submitted values within your queries to reduce the chances of sql injection.
$sql = "
UPDATE
foo_table
SET
bar_field = '".mysql_real_escape_string($bar_value)."',
WHERE
baz_field = $baz_value
";
As others have pointed out the mysql functions are deprecated in PHP 5.5.0, and removed in PHP 7.0.0. Mysqli is a similar an alternative extension.
So I've searched through some posts, and I've seen that I can't use a HTML form within another HTML form.
Like:
<form method="post" action="x.php">
<input type="..."/>
<form method="post" action="x.php">
<input type="..."/>
</form>
</form>
Ok, but my problem is that I want to make a different page, which contains HTML code like this:
<?php
if(isset($_GET['vote']) && $_GET['vote']=='yes'){
echo 'vote successfully inserted';
}
# gets the email value from MAIN form
$email = isset($_POST['email'] : $_POST['email'] : NULL;
#grab the infos from bd for the user with that email,
$stmt = $db->prepare('SELECT name,email,vote FROM tbl WHERE email=:e');
$stmt->execute(array(':e'=>$email));
while($row = $stmt->fetch(PDO::FETCH_OBJ)){
if($row->vote == 'no'){ # IF THE USER DIDN'T VOTED, THEN
if(isset($_POST['vote'])){ # IF THE <a> IS PRESSED, UPDATE DB
$sql = "UPDATE tbl SET vote='yes' WHERE email=:e";
$s = $db->prepare($sql);
$s->execute(array(':e'=>$email));
}
}
?>
<table>
<tr>
<td>Name</td>
<td>Email</td>
<td>Address</td>
<td>Vote</td>
</tr>
<tr>
<td><?php echo $row->name;?></td>
<td><?php echo $row->email;?></td>
<td><?php echo $row->address;?></td>
<td>
<form method="POST" action="" id="SECOND">
VOTE!
</form>
</td>
</tr>
</table>
<?php } // end while() ?>
Then, under this <table>, I have another form:
<form action="" method="POST" id="MAIN>
<input type="text" name="email" placeholder="email"><br/>
<input type="submit" value="Login" name="submit"/>
</form>
The project is about a electoral campaign, where a user can 'login' with this email address, and submit his vote.
So,
when the user requests the page, the MAIN form will pop-up, he will fill in his email, and will press submit.
he is redirected to the same page (I'm hiding the MAIN form), and the table will pop-up.
now, the user can select his favorite candidate, and press on the <a> link - his vote will be stored in db, updating the vote field from, initially 'no' to 'yes'.
Now, the prob is that when the <a> link is pressed, the update in the db doesn't take place.
The reason the link doesn't update the database is because the form is not being submitted. Change the to an
<input type="submit" value="VOTE!">
Sorry I'm a bit of a noob when it comes to PHP but I just wondered if someone had an idea on how I could solve this PHP/SQL problem.
I have a PDO statement that gets all users from a database.
With the array of users from the database I create a foreach loop to display all of the users in a table which I want to use to select a specific user, enter a number in the row of the user I select, then click submit and store the users name and also the number. I will use this information to populate another database later.
My question is, I cant seem to reference the user or the number in the table to extract the user and number I enter. When I try and request the numbered entered in the index.php, it will only ever display a number if I enter a number for a the final user in the table. When I try and view the FullName it never works and I get 'Undefined index: FullName' error.
I also specified to 'POST in the form but it doesnt seem to be doing that.
Does anyone have any ideas?
Thanks
//function.php
function getName($tableName, $conn)
{
try {
$result = $conn->query("SELECT * FROM $tableName");
return ( $result->rowCount() > 0)
? $result
: false;
} catch(Exception $e) {
return false;
}
}
//form.php
<form action "index.php" method "POST" name='form1'>
<table border="1" style="width:600px">
<tr>
<th>Name</th>
<th>Number Entered</th>
<tr/>
<tr>
<?php foreach($users as $user) : ?>
<td width="30%" name="FullName">
<?php echo $user['FullName']; ?>
</td>
<td width="30%">
<input type="int" name="NumberedEntered">
</td>
</tr>
<?php endforeach; ?>
</table>
<input type="submit" value="submit"></td>
</form>
//index.php
$users = getName('users', $conn);
if ( $_REQUEST['NumberedEntered']) {
echo $_REQUEST['NumberedEntered'];
echo $_REQUEST['FullName'];
}
The variable FullName isn't transmitted by your form to index.php. Only values of form elemnts are sent. You can add a hidden form field, that contains FullName like this:
<input type="hidden" name="FullName" value="<?php echo $user['FullName']">
But your second problem is, that your foreach loop will create several input fields with the exact same name. You won't be able to recieve any of the entered numbers, except the last one. have a look at this question for possible solutions.
Update
Putting each row in individual form tags should solve your problem:
<?php foreach($users as $user) : ?>
<form action="index.php" method="POST">
<tr>
<td align="center" width="40%" >
<?php echo $user['FullName']; ?>
<input type="hidden" name="FullName" value="<?php echo $user['FullName']; ?>" />
</td>
<td width="30%">
<input name="NumberedEntered"/>
</td>
<td>
<input type="submit" value="submit"/>
</td>
</tr>
</form>
<?php endforeach; ?>
Dunno if the title makes sense, but I have a variable which would to put it in basic terms would be called like this:
$_POST['something'+$variable2]
I have a form which is for editing selected records, this form contains entries for all previously selected records:
<form name="input" action="editcar.php" method="POST">
<input type="submit" value="Yes">
while($row = mysqli_fetch_assoc($result))
{
echo'
</div>
<table style="color:white">
<tr>
<td style="text-align:right">Manufacture:</td><td><input type="text" name="manufacture'.$row['carIndex'].'" value="'.$row['make'].'"></td>
<td style="text-align:right">Model: </td><td><input type="text" name="model'.$row['carIndex'].'" value="'.$row['model'].'"></td>
</tr>
<tr>
<td style="text-align:right">Colour: </td><td><input type="text" name="colour'.$row['carIndex'].'" value="'.$row['colour'].'"></td>
<td style="text-align:right">Reg: </td><td><input type="text" name="reg'.$row['carIndex'].'" value="'.$row['Reg'].'"></td>
</tr>
<tr>
<td style="text-align:right">Price: </td><td><input type="text" name="price'.$row['carIndex'].'" value="'.$row['price'].'"></td>
<td style="text-align:right">Mileage: </td><td><input type="text" name="mileage'.$row['carIndex'].'" value="'.$row['miles'].'"></td>
</tr>
<tr>
<td style="text-align:right">Max MPH: </td><td><input type="text" name="mph'.$row['carIndex'].'" value="'.$row['mph'].'"></td>
<td style="text-align:right">MPG: </td><td><input type="text" name="mpg'.$row['carIndex'].'" value="'.$row['mpg'].'"></td>
</tr>
</table>
</form>
</div> ';
}
?>
</form>
The form is looped for each record previously chosen, to enable mass editing. The isue arouses when I realised I'd have multiple inputs with the same name, so I did:
<input type="text" name="model'.$row['carIndex'].'" value="'.$row['model'].'">
Placing the primary key of the record it was currently tired to on the end of it's name. Which seemed like a logical way to go about things.
However now I need to call these variables to place in the mysql query and I dunno how to do that, or even if I can.
I have the selected records saved in an array so I have:
foreach ($postid as $carID)
{
$query = "stuff";
mysqli_query($db, $query);
}
Each loop has $carID containing the variables that was put on the end of the form input names.
So something like:
$_POST['something'+$variable2]
is all I can think of but doesn't work.
Any method that works for my overall code is welcome not just a solution to the issue I've made.
Actually your way should work. Just replace the + with . in $_POST['something'+$variable2].
My tip is: use an array as name in your html instead:
<input type="text" name="model[]" value="'.$row['model'].'">
On php-Side you can loop through all $_POST['model'] since its an array now.
You can add the index for every entry in your html, too:
<input type="text" name="model['.$row['carIndex'].']" value="'.$row['model'].'">
PHP uses a dot for concatenation, not + like Java and Javascript:
$_POST['something' . $variable2]
Try something like this:
<form ...>
<?php
while($row = mysqli_fetch_assoc(...):
$index = $row['carIndex'];
?>
<input type="text" name="carmodel[<?php echo $index?>][model]" value="<?php echo $row['model'] ?>">
<?php endforeach; ?>
</form>
This way you will have the data stored in $_POST['carmodel'] as an array indexed by carIndex value as the structure of data in $_POST is defined by names of inputs, here you will have names likee carmodel[1][model] for example so then in post it will be in $_POST['carmodel'][1][model]
you can read here as well
How would I create this array structure in an HTML form?
So here is goes. I have a website that has a login. Upon a successful login, a session variable called user is created which contains an array of the userid, username, email and so on. Then from there I have links to other pages. What is giving me trouble is that I have a page called membership.php. This page does a select query for the userid, username, email and generates a table with all of the users. There is also a submit button beside each user that is entitled "Edit". When this button is clicked it redirects to a page edit_account.php. My goal here is when i click on the edit button, a session variable is created containing the userid of that specific user. Then when it redirects to the edit_account.php page I can use that session as part of my select statement to gather data from the table and then edit that users details. Below is a snipit of my code so you can see what I am talking about.
<?php
// First we execute our common code to connection to the database and start the session
require("common.php");
// At the top of the page we check to see whether the user is logged in or not
if(empty($_SESSION['user']))
{
// If they are not, we redirect them to the login page.
header("Location: ../../index.php");
// Remember that this die statement is absolutely critical. Without it,
// people can view your members-only content without logging in.
die("Redirecting to index.php");
}
// We can retrieve a list of members from the database using a SELECT query.
// In this case we do not have a WHERE clause because we want to select all
// of the rows from the database table.
$query = "
SELECT
id,
roleid,
username,
email
FROM user
";
try
{
// These two statements run the query against your database table.
$stmt = $db->prepare($query);
$stmt->execute();
}
catch(PDOException $ex)
{
// Note: On a production website, you should not output $ex->getMessage().
// It may provide an attacker with helpful information about your code.
die("Failed to run query: " . $ex->getMessage());
}
// Finally, we can retrieve all of the found rows into an array using fetchAll
$rows = $stmt->fetchAll();
if (isset($_POST['Edit'])) {
$_SESSION['id'] = $_POST['id'];
header("Location: edit_account.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Registration</title>
<link href="../../css/default.css" rel="stylesheet" type="text/css" />
</head>
<div id="container">
<div id="header">
<h1>
</h1>
</div>
<div id="navigation">
<ul>
<li>Home</li>
<li>About</li>
<li>Services</li>
<li>Contact us</li>
<li>Logout</li>
</ul>
</div>
<div id="content">
<h2>
Users
</h2>
<form action="" method="post">
<table border="0" align="left" cellpadding="25px">
<tr>
<th>ID</th>
<th>Role ID</th>
<th>Username</th>
<th>E-Mail Address</th>
</tr>
<?php foreach($rows as $row): ?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['roleid']; ?></td> <!-- htmlentities is not needed here because $row['id'] is always an integer -->
<td><?php echo htmlentities($row['username'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlentities($row['email'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><input name="Edit" type="submit" value="Edit" /></td>
<td><input name="id" type="hidden" value="<?php echo $row['id']; ?>" /></td>
</tr>
<?php
endforeach;
?>
</tr>
</table>
</form>
</div>
<div id="footer">
Copyright © 2013
</div>
</div>
<body>
</body>
</html>
I believe the problem resides in the block of code:
if (isset($_POST['Edit'])) {
$_SESSION['id'] = $row['id'];
header("Location: edit_account.php");
}
But I have tried many things and nothing seems to work. Also on edit_account.php page I have this code at the top:
echo '<pre>';
var_dump($_SESSION);
echo '</pre>';
which spits out everything in the session variable. When I select the submit button and it redirects, this is the output of the above code.
array(2) {
["user"]=>
array(4) {
["id"]=>
string(1) "1"
["username"]=>
string(5) "admin"
["roleid"]=>
string(1) "1"
["email"]=>
string(15) "admin#admin.com"
}
["id"]=>
NULL
}
Thank you in advance for the help. Anything is greatly appreciated.
The main problem is that you're basically building a form that looks (stripping out all the fluff html):
<form>
<input name="Edit" type="submit" value="Edit" />
<input name="id" type="hidden" value="foo" />
<input name="Edit" type="submit" value="Edit" />
<input name="id" type="hidden" value="bar" />
<input name="Edit" type="submit" value="Edit" />
<input name="id" type="hidden" value="baz" />
etc...
</form>
There's just ONE form, with multiple submit buttons, and multiple copies of the same hidden field with the same name. As such, PHP will use the LAST hidden id value to populate $_POST with. There is NO way for PHP to tell which of the many submit buttons was clicked, or that it should try to use the id value next to that one particular submit button - that's not how HTTP forms work.
You need something more like this:
<table>
<tr><td><form><input type="hidden" name="id" value="foo"><input type="submit"></form></td></tr>
<tr><td><form><input type="hidden" name="id" value="bar"><input type="submit"></form></td></tr>
<tr><td><form><input type="hidden" name="id" value="baz"><input type="submit"></form></td></tr>
etc..
</table>
Note now EACH row has its OWN form, with one submit button and one hidden field within. This way, only that ONE hidden field is submitted, and you'll get the proper id value showing up in your PHP code.
put form code in each table row not on the whole table a single form.
another problem is u login from admin account and u are making changes of the admin session variable so declare another session variable for it.
or u can also put the update code at the starting of the page that either the form is submited so update the user data than no need of making changes in the session variable.
This is great. Thank you Marc B. Exactly what I was looking for. This is the html code:
<?php foreach($rows as $row): ?>
<tr>
<td> <form action="" method="post"> <?php echo $row['id']; ?> </form> </td>
<td> <form action="" method="post"> <?php echo $row['roleid']; ?> </form> </td>
<td> <form action="" method="post"> <?php echo htmlentities($row['username'], ENT_QUOTES, 'UTF-8'); ?> </form> </td>
<td> <form action="" method="post"> <?php echo htmlentities($row['email'], ENT_QUOTES, 'UTF-8'); ?> </form> </td>
<td> <form action="" method="post"> <input name="Edit" type="submit" value="Edit" /> <input name="id" type="hidden" value="<?php echo $row['id']; ?>" /> </form> </td>
</tr>
<?php endforeach; ?>
And I can successfully set a session using:
if (isset($_POST['Edit'])) {
$_SESSION['id'] = $_POST['id'];
header("Location: edit_account.php");
}
But it seems I have ran into another problem:( I also want to add a delete button on each row to delete that user account. Right now this is how it looks:
<td> <form action="" method="post"> <input name="Delete" type="submit" value="Delete" /> <input name="id" type="hidden" value="<?php echo $row['id']; ?>" /> </form> </td>
And the php code used is:
if (isset($_POST['Delete'])) {
// Everything below this point in the file is secured by the login system
// We can retrieve a list of members from the database using a SELECT query.
// In this case we do not have a WHERE clause because we want to select all
// of the rows from the database table.
$query = "
DELETE
FROM user
WHERE
id = :id
";
// The parameter values
$query_params = array(
':id' => $_POST['id']
);
try
{
// These two statements run the query against your database table.
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch(PDOException $ex)
{
// Note: On a production website, you should not output $ex->getMessage().
// It may provide an attacker with helpful information about your code.
die("Failed to run query: " . $ex->getMessage());
}
// Finally, we can retrieve all of the found rows into an array using fetchAll
$rows = $stmt->fetch();
// This redirects the user back to the members-only page after they register
header("Location: ../adminindex.php");
// Calling die or exit after performing a redirect using the header function
// is critical. The rest of your PHP script will continue to execute and
// will be sent to the user if you do not die or exit.
die("Redirecting to adminindex.php.php");
}
My problem is the redirection. When I click on the Delete button it actually runs the query but afterwards it just redirects to memberlist.php but the page is blank!? Why would this be happening? Is there something I am missing?I have tried changing the header location with no success. Thanks for the help!