I have a register and login PHP script, that uses sessions and will display each users name when they log in. I also have a form that they can fill and is added to a mysql database. Is it possible so that only the user that filled in THEIR form can see it when its displayed? Currently whenever any user fills the form its displayed to every user.
<?PHP
require_once("./include/membersite_config.php");
if(!$fgmembersite->CheckLogin())
{
$fgmembersite->RedirectToURL("login.php");
exit;
}
?>
<!DOCTYPE>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title></title>
<link rel="STYLESHEET" type="text/css" href="style/fg_membersite.css">
</head>
<body>
<div id='fg_membersite_content'>
<h2>Product control page</h2>
<p>
Logged in as: <?= $fgmembersite->UserFullName() ?>
</p>
<p>Here you can see your Current Products:</p>
<?php
$con = mysql_connect("localhost","root","password");
if (!$con){
die("Can not connect: " . mysql_error());
}
mysql_select_db("trackerweb",$con);
$result = mysql_query("SELECT Name_of_Product FROM Product_Tracker");
while ($row = mysql_fetch_assoc($result)) {
echo $row['Name_of_Product'];
echo "<br />";
mysql_query($query);
}
mysql_close($con);
?>
<p>
<a href='add_customer.php'>Add a new product </a>
</p>
<p>
<a href='view.php'>View all product details</a>
</p>
<p>
<a href='login-home.php'>Home</a>
</p>
</div>
</body>
</html>
I only need to display the name of the product when they fill in the form on the same page.
This is the form:
<?php
require_once("/extlib/vdaemon/vdaemon.php");
require_once("./core/config.php");
$_SESSION['user']= ['$fgmembersite->UserFullName'];
?>
<html>
<head>
<style type="text/css">
body {
background: #e4e4e4;
}
.form {
width: 600px;
margin: 0 auto;
background: #fff;
padding: 45px;
border: 1px solid #c2c2c2;
}
.error {
color: #AA0000
}
.controlerror {
background-color: #ffffdd;
border: 1px solid #AA0000;
}
.input {
width: 300px;
height: 35px;
margin-left: 10px;
}
</style>
</head>
<body>
<div class="form">
<?php
$msg = $_GET['msg'];
if ( $msg == '1' ) {
echo '<p>Your information was submitted successfully.</p>';
}
?>
<form action="core/process.php" method="post" id="registration" >
<input type="hidden" name="formID" value="Product_Tracker" />
<p>Name of product:<input type="text" name="Name of Product" class="input" />
<p>Please select the tests that were done on the product.</p>
<p>In Circuit Test (ICT): Yes: <input type="radio" name="ICT" value="yes" /> No: <input type="radio" name="ICT" value="no" /></p>
<p>Visual Inspection: Yes: <input type="radio" name="Visual Inspection" value="yes" /> No: <input type="radio" name="Visual Inspection" value="no" /></p>
<p>XRAY: Yes: <input type="radio" name="XRAY" value="yes" /> No: <input type="radio" name="XRAY" value="no" /></p>
<p>Automated Optical Inspection (AOI): Yes: <input type="radio" name="AOI" value="yes" /> No: <input type="radio" name="AOI" value="no" /></p>
<!--<p>Checkbox1 <input type="checkbox" name="checkbox" value="checkbox1" /> Checkbox2: <input type="checkbox" name="checkbox" value="checkbox2" /></p>-->
<input type="submit" value="Submit" />
<p>
<a href='access-controlled.php'>Back</a>
</p>
</form>
</div>
</body>
</html>
<?php VDEnd(); ?>
Related
I have an assignment to create the web page. One of the points is to make able to change the style of the text through checkboxes. Web programming is not my primary areas, (I am mostly in C#). I don't know how to do it through PHP, as we have started learning recently.
There is my PHP code.
<?php
$firstName = "Yaroslav";
$lastName = "Yatsyk";
$studentID = "101343887";
$checks = [];
$courses = array("COMP1230"=>"Advanced Web Programming", "COMP2129" => "Advanced Object-Oriented Programming", "COMP2130" => "Application Development using Java",
"COMP2138" => "Advanced Database Development","COMP2147" => "System Analysis, Design And Testing", "GSCI1003" => "Statistics");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Assignment 1</title>
<meta name="description" content="Sending data by GET/POST method">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Yaroslav Yatsyk">
<link rel="stylesheet" href="101343887.css">
</head>
<body>
<h1>
<?php
echo $firstName . " " . $lastName . " - " . $studentID;
?>
</h1>
<form action="101343887.php" action="POST">
<section id="textFiled">
Name: <input type="text" value="<?php echo $firstName?> " name="name" required>
<br><br>
Surname: <input type="text" value="<?php echo $lastName?>" name="surname" required>
<br><br>
Student ID: <input type="text" value="<?php echo $studentID?>" name="id" required>
<br><br>
Class: <input list = "classes" name="classes" id="classes" required>
<datalist id="classes">
<?php
foreach($courses as $key=>$value){
echo "<option>".$key."</option>"."<br />";
}
?>
</datalist>
</section>
<br>
<section id="checkBoxes">
<input type="checkbox" name="check[]" id="Strong" value="strong">
<label for="Strong">Strong</label>
<br><br>
<input type="checkbox" name="check[]" id="Underline" value="underline">
<label for="Underline">Underline</label>
<br><br>
<input type="checkbox" name="check[]" id="Uppercase" value="uppercase">
<label for="Uppercase">Uppercase</label>
</section>
<br><br>
<section id="radios">
<input type="radio" name="12ptx" id="12ptx" value="12pt">
<label for="12ptx">12pt</label>
<br><br>
<input type="radio" name="18ptx" id="18ptx" value="18pt">
<label for="18ptx">18pt</label>
<br><br>
<input type="radio" name="24ptx" id="24ptx" value="24pt">
<label for="24ptx">24pt</label>
</section>
<br>
<input type="submit" value="Submit">
</form>
<section id="output" style="height: 150px; width: 150px;">
<h2>
<?php
if(filter_input(INPUT_POST,'name',FILTER_SANITIZE_STRING) && filter_input(INPUT_POST,'surname',FILTER_SANITIZE_STRING) && (
filter_input(INPUT_POST,'id',FILTER_SANITIZE_STRING)
))
{
$firstName = $_POST['name'];
$lastName = $_POST['surname'];
$studentID = $_POST['id'];
if(isset($_POST['check']) && !empty($_POST['check'])) {
$checks = $_POST['check'];
// Add code
}
}
echo $firstName . " " . $lastName . " " . $studentID;
?>
</h2>
</section>
<div>
<?php
if(isset($_POST["classes"])) {
$key = $_POST["classes"];
}
echo $courses[$key];
?>
</div>
<?php
echo "<hr>";
echo show_source("101343887.php");
?>
<script src=https://my.gblearn.com/js/loadscript.js></script>
</body>
</html>
There is my CSS code
#textFiled input[type=text] {
width: 25%;
height: 25%;
padding: 10px 15px;
margin: 8px 0;
box-sizing: border-box;
}
#textFiled input[type=checkbox] {
width: 25%;
height: 25%;
padding: 10px 15px;
margin: 8px 0;
box-sizing: border-box;
}
.uppercase {
text-transform: uppercase;
}
.underline {
text-decoration: underline;
}
.strong {
font-weight: bold;
}
Please do not be toxic, or do not put minus scores, as I have just begun learning programming at college, and not all things are understandable. I am willing to be better, but I need professional assistance to approach it.
Thank you
I'm trying to add the user session to a table that is filled in when they complete a form. I would then like to display the form only they created on their home page.
<?php
require_once("/extlib/vdaemon/vdaemon.php");
require_once("./core/config.php");
?>
<html>
<head>
<style type="text/css">
body {
background: #e4e4e4;
}
.form {
width: 600px;
margin: 0 auto;
background: #fff;
padding: 45px;
border: 1px solid #c2c2c2;
}
.error {
color: #AA0000
}
.controlerror {
background-color: #ffffdd;
border: 1px solid #AA0000;
}
.input {
width: 300px;
height: 35px;
margin-left: 10px;
}
</style>
</head>
<body>
<div class="form">
<?php
$msg = $_GET['msg'];
if ( $msg == '1' ) {
echo '<p>Your information was submitted successfully.</p>';
}
?>
<form action="core/process.php" method="post" id="registration" >
<input type="hidden" name="formID" value="Product_Tracker" />
**<input type="hidden" name="id_user" value="$_SESSION['id_user']" />**
<p>Name of product:<input type="text" name="Name of Product" class="input" />
<p>Please select the tests that were done on the product.</p>
<p>In Circuit Test (ICT): Yes: <input type="radio" name="ICT" value="yes" /> No: <input type="radio" name="ICT" value="no" /></p>
<p>Visual Inspection: Yes: <input type="radio" name="Visual Inspection" value="yes" /> No: <input type="radio" name="Visual Inspection" value="no" /></p>
<p>XRAY: Yes: <input type="radio" name="XRAY" value="yes" /> No: <input type="radio" name="XRAY" value="no" /></p>
<p>Automated Optical Inspection (AOI): Yes: <input type="radio" name="AOI" value="yes" /> No: <input type="radio" name="AOI" value="no" /></p>
<!--<p>Checkbox1 <input type="checkbox" name="checkbox" value="checkbox1" /> Checkbox2: <input type="checkbox" name="checkbox" value="checkbox2" /></p>-->
<input type="submit" value="Submit" />
<p>
<a href='access-controlled.php'>Back</a>
</p>
</form>
</div>
</body>
</html>
<?php VDEnd(); ?>
When I look on phpMyAdmin when the form gets created the id_user is $_SESSION['id_user'] and not the name of the user that created it.
You didn't echo the value of $_SESSION['id_user'], Try this
<input type="hidden" name="id_user" value="<?php echo $_SESSION['id_user']"; ?> />
I have a problem on pass value $result from different page into another page.
when I POST the value $result into this page. It works fine and I echo it out.
but if i try to pass this $result into isset() form and post it back to self.
The value will become Undefined index.
PAGE1
<?PHP
$connect=mysql_connect('localhost', 'root', '');
$db=mysql_select_db('survey', $connect);
$SQL="SELECT * FROM question";
$data=mysql_query($SQL);
$num=mysql_num_rows($data);
$start=0;
?>
<style type="text/css">
#survey{
width:100%; height:50px;
background:#e6e6e6; border-bottom:solid 1px white;
}
#survey form{
position:relative;
left:320px; top:15px;
float:left;
}
#survey form a{
text-decoration:none;
color:black;
}
.submit{
background-color: transparent;
border: none;
cursor: pointer;
}
</style>
<html>
<div id="container">
<?PHP
if($num<3){
echo "
<div id='create'><a href='question.php'>+ Create a Survey</a></div>
";
}
?>
<?PHP
while($start<$num){
$result=mysql_result($data, $start, 'ID');
$list_num=$start+1;
$ID=$result['ID'];
$list="
<div id='survey'>
<span style='font-size:24px; color:gray; position:relative; float:left; left:10px; top:13px;'>
SURVEY 0$list_num
</span>
<form action='survey.php' method='POST'>
<input class='submit' type='submit' name='submit1' value='View' />
<input type='hidden' name='result' value='$ID'/>
</form>
<form action='update.php' method='POST'>
<input class='submit' type='submit' name='submit2' value='Edit' />
<input type='hidden' name='result' value='$ID'/>
</form>
<form action='delete.php' method='POST'>
<input class='submit' type='submit' name='submit3' value='✕ Delete' />
<input type='hidden' name='result' value='$ID'/>
</form>
</div>
";
echo $list;
$start++;
}
?>
</div>
</html>
PAGE2
<?PHP
$result=$_POST['result'];
$error="";
if(isset($_POST['submit'])){
$question=$_POST['question'];
$answer_a=$_POST['a'];
$answer_b=$_POST['b'];
$answer_c=$_POST['c'];
if($question && $answer_a && $answer_b && $answer_c){
$connect=mysql_connect("localhost", "root", "");
$db=mysql_select_db("survey", $connect) or die("");
$SQL="UPDATE question SET question='$question', answer_a='$answer_a', answer_b='$answer_b', answer_c='$answer_c'
WHERE ID='$result'";
mysql_query($SQL);
$SQL="UPDATE answer SET question='$question', answer_a='0', answer_b='0', answer_c='0'
WHERE ID='$result' ";
mysql_query($SQL);
header("location:create.php");
}
else{$error="<div style='color:white; background:gray; width:200px; height:20px; text-align:center; line-height:20px;'>"
. "Please fill all the field." . "</div>";}
}
?>
<style>
body{
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
}
</style>
<html>
<form action="update.php" method="POST">
Question<br /><input type="text" name="question" placeholder=" Enter your question here" maxlength="50" /><br/><br/>Answer<br/>
a<input type="text" name="a" placeholder=" Answer a" maxlength="50"/>
b<input type="text" name="b" placeholder=" Answer b" maxlength="50"/>
c<input type="text" name="c" placeholder=" Answer c" maxlength="50"/>
<input type="submit" name="submit" value="SAVE"/>
</form>
<?PHP echo $error; ?>
</html>
Hi All thank you very much for help
I have found the solution
I think the problem is when I pass the value to 2nd form, I will need to resend the value again. Here is what I did.
1st one is from previous page, 2nd one is form post to itself
if(isset($_POST['result'])){
$result=$_POST['result'];
echo $result;
}
if(isset($_POST['data'])){
$ID=$_POST['data'];
echo $ID;
}
add another hidden in the form and resend the value
<input type="hidden" name="data" value="<?PHP echo $result;?>"/>
change the mysql value
WHERE... ID='$ID'";
Try editing on page 2 this
<html>
<form action="update.php" method="POST">
To this
<html>
<form action="" method="POST">
I have 2 forms in 1 page that need submitting i seem to be limited because it is for a hotspot by mikrotik.
The login.html in mikrotic router is
<html>
<head><title>...</title></head>
<body>
$(if chap-id)
<noscript>
<center><b>JavaScript required. Enable JavaScript to continue.</b></center>
</noscript>
$(endif)
<center>If you are not redirected in a few seconds, click 'continue' below<br>
<form name="redirect" action="http://domain.name/login.php" method="post">
<input type="hidden" name="mac" value="$(mac)">
<input type="hidden" name="ip" value="$(ip)">
<input type="hidden" name="username" value="$(username)">
<input type="hidden" name="link-login" value="$(link-login)">
<input type="hidden" name="link-orig" value="$(link-orig)">
<input type="hidden" name="error" value="$(error)">
<input type="hidden" name="chap-id" value="$(chap-id)">
<input type="hidden" name="chap-challenge" value="$(chap-challenge)">
<input type="hidden" name="link-login-only" value="$(link-login-only)">
<input type="hidden" name="link-orig-esc" value="$(link-orig-esc)">
<input type="hidden" name="mac-esc" value="$(mac-esc)">
<input type="submit" value="continue">
</form>
<script language="JavaScript">
<!--
document.redirect.submit();
//-->
</script></center>
</body>
</html>
so then my login.php is this
<?php
$mac=$_POST['mac'];
$ip=$_POST['ip'];
$username=$_POST['username'];
$linklogin=$_POST['link-login'];
$linkorig=$_POST['link-orig'];
$error=$_POST['error'];
$chapid=$_POST['chap-id'];
$chapchallenge=$_POST['chap-challenge'];
$linkloginonly=$_POST['link-login-only'];
$linkorigesc=$_POST['link-orig-esc'];
$macesc=$_POST['mac-esc'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>mikrotik hotspot > login</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="expires" content="-1" />
<style type="text/css">
body {color: #737373; font-size: 10px; font-family: verdana;}
textarea,input,select {
background-color: #FDFBFB;
border: 1px solid #BBBBBB;
padding: 2px;
margin: 1px;
font-size: 14px;
color: #808080;
}
a, a:link, a:visited, a:active { color: #AAAAAA; text-decoration: none; font-size:
10px; }
a:hover { border-bottom: 1px dotted #c1c1c1; color: #AAAAAA; }
img {border: none;}
td { font-size: 14px; color: #7A7A7A; }
</style>
<script language="JavaScript">
function fnSubmit (){
var form1Content = document.getElementById("form1").innerHTML;
var form2Content = document.getElementById("form2").innerHTML;
var form3Content = document.getElementById("form3").innerHTML;
document.getElementById("toSubmit").innerHTML=form1Content+form2Content;
document.forms.toSubmit.submit();
}
</script>
</head>
<body>
<!-- $(if chap-id) -->
<form name="sendin" action="<?php echo $linkloginonly; ?>" method="post" id="form1">
<input type="hidden" name="username" />
<input type="hidden" name="password" />
<input type="hidden" name="dst" value="<?php echo $linkorig; ?>" />
<input type="hidden" name="popup" value="true" />
</form>
<script type="text/javascript" src="./md5.js"></script>
<script type="text/javascript">
<!--
function doLogin() {
<?php if(strlen($chapid) < 1) echo "return true;\n"; ?>
document.sendin.username.value = document.login.username.value;
document.sendin.password.value = hexMD5('<?php echo $chapid; ?>' + document.login.password.value + '<?php echo $chapchallenge; ?>');
document.sendin.submit();
return false;
}
//-->
</script>
<!-- $(endif) -->
<div align="center">
Hotspot
</div>
<table width="100%" style="margin-top: 10%;">
<tr>
<td align="center" valign="middle">
Please log on to use the mikrotik hotspot service
</div><br />
<table width="240" height="240" style="border: 1px solid #cccccc; padding: 0px;" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="bottom" height="175" colspan="2">
<!-- removed $(if chap-id) $(endif) around OnSubmit -->
<form method="POST" action="signin.php" id="form2">
First Name<p><input type="text" name="firstname" size="30"></p>
Surname<p><input type="text" name="lastname" size="30"></p>
Email address <font color="red"> (required)</font><p><input type="text" name="email" size="30"></p>
<input type="submit" value="submit" onclick="javascript:fnSubmit();"/>
</form>
<form name="login" id="form3 action="<?php echo $linkloginonly; ?>" method="post" onSubmit="return doLogin()" >
<input type="hidden" name="dst" value="<?php echo $linkorig; ?>" />
<input type="hidden" name="popup" value="true" />
<table width="100" style="background-color: #ffffff">
<tr><td align="right"></td>
<td><input type="hidden" style="width: 80px" name="username" type="text" value="user2"/></td>
</tr>
<tr><td align="right"></td>
<td><input type="hidden" style="width: 80px" name="password" type="password" value="user2"/></td>
</tr>
<tr><td> </td>
<td><td></td></td></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<!-- $(if error) -->
<br /><div style="color: #FF8080; font-size: 9px"><?php echo $error; ?></div>
<!-- $(endif) -->
</td>
</tr>
</table>
<script type="text/javascript">
<!--
document.login.username.focus();
//-->
</script>
</body>
</html>
as you can see im trying to auto submit the username and password
so that the user only inputs his email address, to do this i want to store the email in
a database
with signin.php
which is this
<?php
ini_set('display_errors', 'On');
// Receiving variables
#$pfw_ip= $_SERVER['REMOTE_ADDR'];
#$firstname = addslashes($_POST['firstname']);
#$lastname = addslashes($_POST['lastname']);
#$email = addslashes($_POST['email']);
#$date = addslashes($_POST['date']);
// Validation
if (! ereg('[A-Za-z0-9_-]+\#[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>");
}
if (strlen($email) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>");
}
/* adding user information to the userinfo table */
#$pfw_strQuery = "INSERT INTO userinfo (firstname, lastname, email, creationdate) values ".
"('$firstname', '$lastname', '$email', NOW())";
#$pfw_host = "localhost";
#$pfw_user = "dbusername";
#$pfw_pw = "dbpassword";
#$pfw_db = "database";
$pfw_link = mysql_connect($pfw_host, $pfw_user, $pfw_pw);
if (!$pfw_link) {
die('Could not connect: ' . mysql_error());
}
$pfw_db_selected = mysql_select_db($pfw_db, $pfw_link);
if (!$pfw_db_selected) {
die ('Can not use $pfw_db : ' . mysql_error());
}
//insert new record
$pfw_result = mysql_query($pfw_strQuery);
if (!$pfw_result) {
die('Invalid query: ' . mysql_error());
}
mysql_close($pfw_link);
header('Location: http://www.google.co.uk');
?>
what happens is that the email address is stored in the mysql table
but the form which stores the username and password, does not pass through, and i end up at the login page
what am i missing?
Thanks all
Ok the answer was to eliminate all the javascript in login.php and use a simple form with the signin.php passing through the username and password using pap login. All working and happy a happy bunny
I am currently building a php form utilising the jQuery iPhone style radios (found at http://devgrow.com/iphone-style-switches/). By default the radio value is set to NO in the MySQL table for every new entry, but I am having difficulty submitting the form.
How will the form be able to tell the current status of the radio button (i.e. is it set to yes or no upon submission)? Also what MySQL code would I need to use to update the value in the table? This is the code I have so far.
PHP form code
<!--- iphone checkbox --->
<script type="text/javascript">
$(document).ready( function(){
$(".cb-enable").click(function(){
var parent = $(this).parents('.switch');
$('.cb-disable',parent).removeClass('selected');
$(this).addClass('selected');
$('.checkbox',parent).attr('checked', true);
});
$(".cb-disable").click(function(){
var parent = $(this).parents('.switch');
$('.cb-enable',parent).removeClass('selected');
$(this).addClass('selected');
$('.checkbox',parent).attr('checked', false);
});
});
</script>
<style type="text/css">
.cb-enable, .cb-disable, .cb-enable span, .cb-disable span { background: url(resources/switch.gif) repeat-x; display: block; float: left; }
.cb-enable span, .cb-disable span { line-height: 30px; display: block; background-repeat: no-repeat; font-weight: bold; }
.cb-enable span { background-position: left -90px; padding: 0 10px; }
.cb-disable span { background-position: right -180px;padding: 0 10px; }
.cb-disable.selected { background-position: 0 -30px; }
.cb-disable.selected span { background-position: right -210px; color: #fff; }
.cb-enable.selected { background-position: 0 -60px; }
.cb-enable.selected span { background-position: left -150px; color: #fff; }
.switch label { cursor: pointer; }
.switch input { display: none; }
</style>
</head>
<body style="text-align:left;">
<div style="padding: 15px;">
<span class="loginfail" style="font-size:24px; font-weight: bold">Notifications</span><p>
<?php include("progress_insertcomment.php"); ?>
<?php
// Make a MySQL Connection
mysql_select_db("speedycm_data") or die(mysql_error());
$query_comment = "select * from tbl_alert order by id desc limit 1";
$comment = mysql_query($query_comment, $speedycms) or die(mysql_error());
$row_comment = mysql_fetch_assoc($comment);
$totalRows_comment = mysql_num_rows($comment);
?>
<!--- add notification --->
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<span id="sprytextarea1">
<textarea id='comment' name="comment" style="height: 75px; width:330px;"><?php echo $row_comment['comment']; ?></textarea>
</span>
<p>
<button type="submit">Add</button>
<input type="hidden" name="notc" value="1"/>
</form>
<!--- notification history --->
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table border="0" cellspacing="2" cellpadding="2">
<?php
if ( $row_comment == 0 ) {
echo "<span style='font-size: 11px;'>No current alerts.</span>";
} else {
// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM tbl_alert ORDER BY id DESC")
or die(mysql_error());
while($rows=mysql_fetch_array($result)){ ?>
<tr>
<td>
<?php
echo "<div class='bubble'><div class='pimped'>
<blockquote>" . $rows['comment'] . "
</blockquote></div>
<cite><strong>" . $rows['user'] . "</strong> # " . $rows['date'] . "</cite>
<span style='font-size: 10px;'>
<p>
<a href='editalert.php?id=". $rows['id'] ."' class='form' >Edit</a> • <a href='deletealert.php?id=". $rows['id'] ."' class='form'>Delete</a>
</span>
</div>
";
?>
</td>
<td valign="top" align="center"><div style="padding-left: 30px;"><span style="font-size: 10px;">Completed?</span>
<p class="field switch">
<!--- determine status of notification --->
<?php
$status = $rows['status'];
if ( $status == yes ) {
echo '<input type="radio" id="radio1" name="'.$rows['id'].'" value="no" checked/>
<input type="radio" id="radio2" name="'.$rows['id'].'" value="yes"/>
<label for="radio1" class="cb-enable selected"><span>Yes</span></label>
<label for="radio2" class="cb-disable"><span>No</span></label>';
} else {
echo '<input type="radio" id="radio1" name="'.$rows['id'].'" value="yes"/>
<input type="radio" id="radio2" name="'.$rows['id'].'" value="no" checked/>
<label for="radio1" class="cb-enable"><span>Yes</span></label>
<label for="radio2" class="cb-disable selected"><span>No</span></label>';
}
?>
</p>
</div></td>
</tr>
<tr>
<td></td>
<td align="center"><div style="padding-left: 30px;">
<button type="submit">Update</button>
<input type="hidden" name="notc2" value="1"/>
</div></td>
</tr>
<?php
}
}
?>
</table>
</form>
</div>
code to submit form
<?php
// 6) update notifications
if (array_key_exists('notc2',$_POST)) {
echo "<p style='font-size: 12px;'>Thank you. The notifications have been updated successfully.</p>";
echo "<span style='font-size: 12px;'>
<a onClick=\"history.go(-1)\" class='form'>Return</a>
<p></span>
";
exit;
};
?>
The information will be present within $_POST['<id>'] where <id> corresponds to the row in tbl_alerts as given in your php form:
echo '<input type="radio" id="radio1" name="'.$rows['id'].'" value="no" checked/>
<input type="radio" id="radio2" name="'.$rows['id'].'" value="yes"/>
(emphasis added)
You can (and should) verify that by adding a var_dump($_POST) up the top of your processing script.
It will be hard for your processing script to know the id value though so what you probably want is name the radio as some other name, and then add a hidden form field that will store the id.
ex. your radio buttons would appear:
<input type="radio" id="radio1" name="status" value="no" checked/>
<input type="radio" id="radio2" name="status" value="yes"/>
and then somewhere in your code you have:
echo '<input type="hidden" name="statusid" value="'.$rows['id'].'"/>';
That way, the radio button value will be in $_POST['status'] and the id of the row will be in $_POST['statusid']