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
Related
So I need help with "data.php" . How can I make the "data.php" use foreach and an array instead of writing to text file ?
With this come it makes it so that the information is written down in a txt file
And I need it to be in an Array and to use Foreach .
Weed all of the information to go into an array and then by using Foreach to show it up .
letters.php
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Домашна 3</title>
<style>
body {
font-family: Tahoma;
}
table, td {
margin: auto;
padding: 7px;
width: 50%;
border: 2px solid black;
border-collapse: collapse;
background: #00FFFF;
}
th {
font-size: 40px;
margin: auto;
padding: 10px;
}
h1 {
margin: auto;
padding: 30px;
background: #bfeaff;
}
input {
margin: 10px;
}
p {
font-size: 20px;
margin: auto;
padding: auto;
}
hr {
margin: 15px;
padding: auto;
}
input[type=submit], input[type=reset] {
padding-top: 10px;
padding-bottom: 10px;
padding-left: 15px;
padding-right: 15px;
}
</style>
</head>
<body>
<form method="post">
<table>
<tr>
<td>
<center>
<h1>СЪЗДАВАНЕ НА ПИСМО/A</h1>
<label for="firstName_Receiver">Име на получател:</label>
<input type="text" id="firstName_Receiver" name="firstName_Receiver" required /><br />
<label for="lastName_Receiver">Фамилия на получател:</label>
<input type="text" id="lastName_Receiver" name="lastName_Receiver" required /><br />
<hr />
<label for="firstName_Sender">Вашето име:</label>
<input type="text" id="firstName_Sender" name="firstName_Sender" required /><br />
<label for="lastName_Sender">Вашата фамилия:</label>
<input type="text" id="lastName_Sender" name="lastName_Sender" required /><br />
<hr />
<p>Съдържания:</p><br />
<textarea name="firstContext" rows="6" cols="60" required></textarea><br /><br />
<textarea name="secondContext" rows="6" cols="60" required></textarea><br /><br />
<p>Послепис:</p><br />
<textarea name="Afterword" rows="4" cols="40" required></textarea>
<hr />
<input type="submit" value="Изпрати" name="Submit" />
<input type="reset" value="Изчисти" />
</center>
</td>
</tr>
</table>
</form>
<?php
require "data.php";
?>
</body>
</html>
data.php
<?php
if (isset($_POST["Submit"]))
{
if (!file_exists("letters.txt"))
{
$letters = fopen("letters.txt", "w+");
fwrite($letters,
"Уважаеми (а), " . $_POST["firstName_Receiver"] . " " . $_POST["lastName_Receiver"] . "<br />" . "\n" .
$_POST["firstContext"] . "<br />" . "\n" .
$_POST["secondContext"] . "<br />" . "\n" .
$_POST["Afterword"] . ", " . $_POST["firstName_Sender"] . " " . $_POST["lastName_Sender"] . "!" . "\n" . "\n"
);
}
else
{
$letters = fopen("letters.txt", "a+");
fwrite($letters,
"<hr />" . "Уважаеми (а), " . $_POST["firstName_Receiver"] . " " . $_POST["lastName_Receiver"] . "<br />" . "\n" .
$_POST["firstContext"] . "<br />" . "\n" .
$_POST["secondContext"] . "<br />" . "\n" .
$_POST["Afterword"] . ", " . $_POST["firstName_Sender"] . " " . $_POST["lastName_Sender"] . "!" . "\n" . "\n"
);
}
fclose($letters);
echo file_get_contents("letters.txt");
}
You can use session and store the data into a new array. Currently I do not have PHP installed on my computer make sure the syntax is correct please.
Please do not forget that the session should be started at the top of the page.
<form method="post">
<table style="text-align: center;">
<tr>
<td>
<h1>СЪЗДАВАНЕ НА ПИСМО/A</h1>
<label for="firstName_Receiver">Име на получател :</label>
<input type="text" id="firstName_Receiver" name="firstName_Receiver" /><br />
<label for="lastName_Receiver">Фамилия на получател:</label>
<input type="text" id="lastName_Receiver" name="lastName_Receiver" /><br />
<hr />
<label for="firstName_Sender">Вашето име:</label>
<input type="text" id="firstName_Sender" name="firstName_Sender" /><br />
<label for="lastName_Sender">Вашата фамилия:</label>
<input type="text" id="lastName_Sender" name="lastName_Sender" /><br />
<hr />
<p>Съдържания:</p><br />
<textarea name="firstContext" rows="6" cols="60"></textarea><br /><br />
<textarea name="secondContext" rows="6" cols="60"></textarea><br /><br />
<p>Послепис:</p><br />
<textarea name="Afterword" rows="4" cols="40"></textarea>
<hr />
<input type="submit" value="Submit" name="Submit" />
<input type="reset" value="Изчисти" />
<button type="submit" name='save'>Save</button>
</td>
</tr>
</table>
</form>
<?php
session_start();
if ( (isset($_POST["Submit"]) || isset($_POST['save'])) && !empty($_POST['firstName_Receiver']) ){
$_SESSION['DaraArray'][] = $_POST;
}
if(isset($_POST['save']) && isset($_SESSION['DaraArray'])){
//Do what you want and unset the $_SESSION['DataArray'];
foreach($_SESSION['DaraArray'] as $Data){
// Your code inside loop
echo '<pre';
print_r($Data);
echo '</pre>';
}
unset($_SESSION['DaraArray']);
}
?>
HTML From data not getting submitted not even the PHP page is being loaded where a form is there.
In below Code, I have used From above the table from where I will have to select table's row using checklist after clicking submit button, but current pade is not even being load to show me even error and blank page itself.
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title></title>
<style media="screen">
#listdiv1{
position: relative;
display:block;
left:15%;
}
body{
background-color: rgb(231, 187, 82);
}
th{
font-variant: small-caps;
font-weight: lighter;
color:red;
}
</style>
</head>
<body >
<div id="listdiv1" style="background-
color:red;width:1400px;height:900px;position:relative;top:20px;">
<div id="listDivIn2" style="background-color:blue;width:1400px;height:900px;display:inline-block;position: absolute;">
<h1 style="margin-left:500px;font-family:Trebuchet MS;font-variant: small-caps;"> Customers List</h1>
<div style="position:absolute;top:80px;margin-left:60px;">
<label style="font-family:Trebuchet MS;color:rgb(187, 218, 177);">Customer_Name</label><input type="text" name="cn_tosearch" placeholder="enter name" style="position: absolute;width:300px;margin-left:14px" /></br>
<label style="margin-left:30px;font-family:Trebuchet MS;color:rgb(187, 218, 177);">Date</label><input type="text" name="Date_tosearch" placeholder="enter date" style="position: absolute;margin-left:68px;width:300px;" /></div></br>
<button type="button" class="btn btn-secondary" style="position:absolute;top:150px;left:280px;">Search</button>
<div id="divtable" style="background-color:black;width:1200px;height:570px;position:absolute;top:220px;margin-left:90px;" >
<table style="width:100%;position:absolute;color:red;margin-left:35px;top:10px;" >
<?php
$dbs=mysqli_connect("localhost","root","","biz_dairy")
or die("connection error");
$q="select * from add_customer";
$result=mysqli_query($dbs,$q)
or die("error in query");
$data=mysqli_fetch_all($result);
mysqli_close($dbs);
$c=count($data);
echo "<tr><th>date</th><th>name</th><th>fanme</th><th>gender</th><th>mob_no</th><th>email</th><th>address</th><th>balance</th></tr>";
echo '<form name="register" method="POST" action="$_SERVER[\'PHP_SELF\']" >';
for ($i = 0; $i <= $c-1; $i++)
{
echo '<input type="checkbox" name="delete[]" value="delete" style="position:relative;top:34px;left:6px;" /><tr>';
echo '<td>'.$data[$i][0].'</td>';
echo '<td>'.$data[$i][1].'</td>';
echo '<td>'.$data[$i][2].'</td>';
echo '<td>'.$data[$i][3].'</td>';
echo '<td>'.$data[$i][4].'</td>';
echo '<td>'.$data[$i][5].'</td>';
echo '<td>'.$data[$i][6].'</td>';
echo '<td>'.$data[$i][7].'</td>';
echo '</tr><br />';
}
echo "</form>";
echo "</table>";
echo "</div>";
echo '<input type="submit" value="delete" name="submit" style="position:absolute;top:820px;left:600px;">';
echo " </form> ";
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js" integrity="sha384-vZ2WRJMwsjRMW/8U7i6PWi6AlO1L79snBrmgiDpgIWJ82z8eA5lenwvxbMV1PAh7" crossorigin="anonymous"></script>
To submit a form without JavaScript/jQuery we must need to use form open/close tags and submit button.
You forgot to use the form open tag and submit button for the form:
Form open tag:
<form action="" method="post">
Submit button to submit the form:
<input type="submit" name="submit" value="search">.
I have edited your code with comments, Please try the below updated script:
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Stack - QA</title>
<style media="screen">
#listdiv1{
position: relative;
display:block;
left:15%;
}
body{ background-color: rgb(231, 187, 82); }
th {
font-variant: small-caps;
font-weight: lighter;
color:red;
}
</style>
</head>
<body>
<div id="listdiv1" style="background-
color:red;width:1400px;height:900px;position:relative;top:20px;">
<div id="listDivIn2" style="background-color:blue;width:1400px;height:900px;display:inline-block;position: absolute;">
<!-- form open tag with action= path-to-action-page and method = get/post attribute -->
<form action="" method="post">
<h1 style="margin-left:500px;font-family:Trebuchet MS;font-variant: small-caps;"> Customers List</h1>
<div style="position:absolute;top:80px;margin-left:60px;">
<label style="font-family:Trebuchet MS;color:rgb(187, 218, 177);">Customer_Name</label><input type="text" name="cn_tosearch" placeholder="enter name" style="position: absolute;width:300px;margin-left:14px" /></br>
<label style="margin-left:30px;font-family:Trebuchet MS;color:rgb(187, 218, 177);">Date</label><input type="text" name="Date_tosearch" placeholder="enter date" style="position: absolute;margin-left:68px;width:300px;" /></div></br>
<input type="submit" class="btn btn-secondary" name="submit" value="Search" style="position:absolute;top:150px;left:280px;">
</form>
<div id="divtable" style="background-color:black;width:1200px;height:570px;position:absolute;top:220px;margin-left:90px;" >
<table style="width:100%;position:absolute;color:red;margin-left:35px;top:10px;" >
<?php
$dbs=mysqli_connect("localhost","root","","biz_dairy")
or die("connection error");
$q="select * from add_customer";
$result=mysqli_query($dbs,$q)
or die("error in query");
$data=mysqli_fetch_all($result);
mysqli_close($dbs);
$c=count($data);
echo "<tr><th>date</th><th>name</th><th>fanme</th><th>gender</th><th>mob_no</th><th>email</th><th>address</th><th>balance</th></tr>";
echo '<form name="register" method="POST" action="$_SERVER[\'PHP_SELF\']" >';
for ($i = 0; $i <= $c-1; $i++)
{
echo '<input type="checkbox" name="delete[]" value="delete" style="position:relative;top:34px;left:6px;" /><tr>';
echo '<td>'.$data[$i][0].'</td>';
echo '<td>'.$data[$i][1].'</td>';
echo '<td>'.$data[$i][2].'</td>';
echo '<td>'.$data[$i][3].'</td>';
echo '<td>'.$data[$i][4].'</td>';
echo '<td>'.$data[$i][5].'</td>';
echo '<td>'.$data[$i][6].'</td>';
echo '<td>'.$data[$i][7].'</td>';
echo '</tr><br />';
}
?>
</table> <!-- close tabel -->
</div>
<!-- scripts -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js" integrity="sha384-vZ2WRJMwsjRMW/8U7i6PWi6AlO1L79snBrmgiDpgIWJ82z8eA5lenwvxbMV1PAh7" crossorigin="anonymous"></script>
Recently im trying to do a model view controller for my software engneering course project. My device model functions are all working fine except for the function listallmydevices() idk whats going on and no errors are visible.
Note i've changed my function to another list function from another class and its working fine except for the device
<html>
<head>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
</head>
<style>
.dropdown-submenu
{
position: relative;
}
.dropdown-submenu .dropdown-menu
{
top: 0;
left: 100%;
margin-top: -1px;
}
</style>
<form action="../prototype/mvc/DeviceController.php" method="post" enctype="multipart/form-data">
<label for="id">ID:</label>
<input type="text" name="ID" >
<br><br>
<label for="username">Device Name:</label>
<input type="text" id="un" name="Name">
<br><br>
<label for="lastname">Date:</label>
<input type="text" name="Date">
<br><br>
<label for="fs">Amount:</label>
<input type="text" name="Amount">
<br><br>
<label for="ls">Price:</label>
<input type="text" name="Price">
<br><br>
<label for="mail">Brand:</label>
<input type="mail" name="Brand">
<br><br>
<label for="password">MarketingToolsID:</label>
<input type="password" name="MTID">
<br><br>
<label for="password">Tochange: </label>
<input type="password" name="edit">
<br><br>
<label for="password">Tochange: </label>
<select name="Cateogry">
<option>Price </option>
<option>Amount </option>
<option> Name</option>
<option> </option>
<option> </option>
</select>
<br>
<input type="submit" name="DELETEDEVICE" value="DELETE DEVICE">
<input type="submit" name="ADDDEVICE" value="ADD DEVICE" >
<input type="submit" name="VIEWALLDEVICES" value="VIEW ALL DEVICES" >
<input type="submit" name="EDITDEVICE" value="Edit DEVICES" >
</form>
-->
public static function listalldevices()
{
$conn = mysqli_connect("localhost", "root", "", "bioster");
$sql="Select * from device order by DeviceID";
$devicequery= mysqli_query($conn,$sql) or die(mysqli_error($conn));
$i=0;
$result;
while($row= mysqli_fetch_array($devicequery))
{
$devobj=new device($row["DeviceID"]);
$result[$i]=$devobj;
$i++;
}
return $result;
}
Device controller
if(isset($_POST['VIEWALLDEVICES']))
{
$array= Device::listalldevices();
echo "All devices";
for($i=0; $i<count($array); $i++)
{
echo $array[$i]->DeviceID;
echo $array[$i]->Name;
echo $array[$i]->Date;
echo $array[$i]->Amount;
echo $array[$i]->Price;
echo $array[$i]->Brand;
}
} //check this not wotking
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(); ?>
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