I'm making a school project, where I shall be able to load a php named: main_login.php through a javascript function called overvågning(), and then load the php into a div I've made. I can't seem to find anything which should be able to help me.
This is the stuff I've made so far:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Surveillance4you</title>
<style type="text/css">
* {
font-size: 20px;
font-family: Arial;
}
#indhold {
width: 560px;
height: 560px;
margin-left: 651px;
margin-top: 270px;
padding: 20px;
border: 0px;
text-align: center;
}
#indhold input {
padding: 3px;
margin: 5px;
cursor: pointer;
}
body {color:#fff;}
</style>
<script>
function OutputInfo()
{
document.getElementById("indhold").innerHTML="Lavet af:<br> Mads Schiellerup & Frederik Munck<br> Erhversskolen Nordsjælland HTX <br> 10-05-2014<br>Vejleder: Christian Obel"
}
function OutputForside()
{
document.getElementById("indhold").innerHTML="Surveillance4you er en hjemmeside som bruges til at live-streame en video af et overvågningskamera. Dette gøes ved hjælp af en opkobling til vores database, hvor du først kan lave en bruger, og herefter have mulighed for at kunne se diverse kameraer."
}
function overvågning()
{
document.getElementById("indhold").innerid=MLogin
}
</script>
</head>
<body background="https://filemanager.one.com/api/webspace/1/drive/saxenkol.dk/data/Full%20Baggrund.png" onLoad="OutputForside()">
<input type="image" src="https://filemanager.one.com/api/webspace/1/drive/saxenkol.dk/data/Menu%20-%20Forside.png"
onClick="OutputForside()"
style=" position: absolute;
top: 170px;
left: 660px;">
<input type="image" src="https://filemanager.one.com/api/webspace/1/drive/saxenkol.dk/data/Menu%20-%20Overvågning.png"
onClick="MLogin" style=" position: absolute;
top: 170px;
left: 860px;">
<input type="image" src="https://filemanager.one.com/api/webspace/1/drive/saxenkol.dk/data/Menu%20-%20Info.png"
onClick="OutputInfo()" style=" position: absolute;
top: 170px;
left: 1060px;">
<div>
<?php
$form = "";
$form.= "<form method=\"post\" action=\"\">";
$form.= "<div id=\"indhold\">";
$form.= "</div>";
$form.= "</form>";
print $form;
?>
</div>
</body>
</html>
The PHP-file i want my function to get and sent to the container #indhold.
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="text" id="mypassword"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
New updated:
<?php
function overvågning()
{
$form = "";
$form.= "<form method=\"post\" action=\"\"><div id=\indhold\">";
$form.= include 'main_login.php';
$form.= "</div></form>";
print $form;
}
?>
And I've also changed:
onClick="overvågning()"
So when I clicked on this image, it should show the php in container
Halløjsa. If I understand correctly you want to pass the user-input from your form to your javascript function but why are there no inputs and submit button within your form tags? If you were to use the php get method instead of post you could retrive the value from the submitted input directly from the url using the window.location method. See this article:
http://javascriptproductivity.blogspot.dk/2013/02/get-url-variables-with-javascript.html
EDIT:If you are not retrieving user inputs but simply want to load the log in file into the page use php include
<?php
echo "<form method=\"post\" action=\"\"><div id=\"indhold\">";
include 'main_login.php';
echo "</div></form>";
?>
Related
In the code below, I tried to show three records in the card in single row of a table. However, instead it displays only one record per row.
Also, I'm required to pass the item code to a modal popup but couldn't understand how to do that. Despite searching, I can't get complete clarification on how to do this.
My Complete code is as follows:
<!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" />
<link href="../css/bootstrap.min.css" rel="stylesheet">
<link href="../css/business-casual.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Josefin+Slab:100,300,400,600,700,100italic,300italic,400italic,600italic,700italic" rel="stylesheet" type="text/css">
<style>
.card {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
transition: 0.3s;
}
.card:hover {
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
}
.container {
padding: 2px 16px;
}
input[type=text],
input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
/* The Modal (background) */
.modal {
display: none;
/* Hidden by default */
position: fixed;
/* Stay in place */
z-index: 1;
/* Sit on top */
left: 0;
top: 0;
width: 100%;
/* Full width */
height: 100%;
/* Full height */
overflow: auto;
/* Enable scroll if needed */
background-color: rgb(0, 0, 0);
/* Fallback color */
background-color: rgba(0, 0, 0, 0.4);
/* Black w/ opacity */
padding-top: 60px;
}
/* Modal Content/Box */
.modal-content {
background-color: #fefefe;
margin: 5% auto 15% auto;
/* 5% from the top, 15% from the bottom and centered */
border: 1px solid #888;
width: 80%;
/* Could be more or less, depending on screen size */
}
.close {
position: absolute;
right: 25px;
top: 0;
color: #000;
font-size: 35px;
font-weight: bold;
}
</style>
</head>
<body>
<?php
$cnt=0;
$rslt = mysqli_query($conn,"SELECT Name,Size,Style FROM productinfo");
if(!$rslt)
{
die(mysqli_error($conn));
}
else
{
while($row = mysqli_fetch_assoc($rslt))
{
echo "<table width='100%'>";
if($cnt==0)
{
$cnt = $cnt + 1;
echo "<tr>
<td width='30%'>
<div class='card'>
<img src='upload/download.jpg' alt='Avatar' style='width:100%' >
<div class='container'>
<h4><b>".$row['Name']."</b></h4>
<p>".$row['Size']."</p>
</div>
</div>";
?>
<button onclick="document.getElementById('id01').style.display='block'" style="width:auto;">Inquiry</button>
<?php
echo "</td>";
}
else
{
echo "<td width='30%'>
<div class='card'>
<img src='upload/"."download.jpg"."' alt='Avatar' style='width:100%' >
<div class='container'>
<h4><b>".$row['Name']."</b></h4>
<p>".$row['Size']."</p>
</div>
</div>
";
?>
<button onclick="document.getElementById('id01').style.display='block'" style="width:auto;">Inquiry</button>
<?php
echo "</td>";
if($cnt==2)
{
$cnt=0;
echo "</tr>";
}
else
{
$cnt = $cnt + 1;
}
}
}
echo "</table>";
}
?>
<div id="id01" class="modal">
<div align="center">
<form action="ViewProd.php" method="post" role="form" class="modal-content animate" ><br/>
<div class="imgcontainer">
<span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">×</span>
<img src="upload/download.jpg" alt="Avatar" class="avatar">
</div>
<table border="0px" cellpadding="1" cellspacing="0">
<tr >
<td width="25%">
Name
</td>
<td width="100%"> <!--<input type="text" tabindex="1" id="Icode" />-->
<input tabindex='1' accesskey='i' name='Nm' type='text' maxlength='200' id='Nm' width="100%" required="required"/>
</td>
</tr>
<tr >
<td width="25%">
Company Name
</td>
<td>
<input type="text" tabindex="1" name="Compnm" id="Compnm" border="0" required="required"/>
</td>
</tr>
<tr >
<td width="25%">
How do you Know about us?
</td>
<td>
<input type="text" tabindex="1" id="HowKnow" name="HowKnow" />
</td>
</tr>
<tr >
<td width="25%">
Email Address
</td>
<td>
<input type="text" tabindex="1" id="EmailAdd" name="EmailAdd" required="required"/>
</td>
</tr>
<tr >
<td width="25%">
Contact No.
</td>
<td>
<input type="text" tabindex="1" id="Phone" name="Phone" />
</td>
</tr>
<tr>
<td width="25%">
City
</td>
<td>
<input type="text" tabindex="1" id="City" name ="City"/>
</td>
</tr>
<tr >
<td width="25%">
Message
</td>
<td>
<input type="text" tabindex="1" id="Remarks" name="Remarks"/>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<button type="submit">Submit</button>
</td>
</tr>
</table>
</form>
</div>
</div>
<script>
// Get the modal
var modal = document.getElementById('id01');
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
</body>
</html>
BTW, Where is your database connection?
Anyway...
1) On your first loop, inside the first condition, you increment $cnt by one, then on the condition below before the loop repeats, else will also increment $cnt. I also made your code lesser, but with the same display.
echo '<table width="100%">';
while($row = mysqli_fetch_assoc($rslt)){
if($cnt == 0){
echo '<tr>';
}
echo ' <td width="30%">
<div class="card">
<img src="upload/download.jpg" alt="Avatar" style="width:100%" >
<div class="container">
<h4><b>'.$row['Name'].'</b></h4>
<p>'.$row['Size'].'</p>
</div>
</div>';
?>
<button class="view-data" data-artid="<?=($row['id'])?>" onclick="document.getElementById('id01').style.display='block'" style="width:auto;">Inquiry</button>
<?php
echo '</td>';
if($cnt == 2){
$cnt = 0;
echo '</tr>';
} else {
$cnt = $cnt + 1;
}
}
echo '</table>';
2) Your second concern requires more work. You will need to use Ajax for this.
First, lets assign a class attribute and set the id of each data to each of their corresponding button, which you will notice on the code on item #1. You also have to indicate the id column on your query (lets assume that you call named it id, just replace it with the right one):
$rslt = mysqli_query($conn,"SELECT id, Name,Size,Style FROM productinfo");
Then lets create the script that will listen to the button when it is clicked:
$(document).on('click', '.view-data', function(){
var elem = $(this),
id = elem.attr('data-artid');
$.ajax({
method: 'POST',
url: 'getdata.php',
data: {'id' : id},
dataType: 'json',
success: function(result){
$("#Nm").val(result.Name);
$("#Compnm").val(result.CompanyName); /** REPLACE NECESSARY COLUMN NAME **/
/** DO THE REST HERE WITH THEIR RESPECTIVE COLUMN NAME **/
}
});
});
We have to create the getdata.php file, which you'll notice in our script above. That is where we will get the corresponding data of the clicked button.
<?php
/*** INCLUDE YOUR DB CONNECTION HERE ***/
$stmt = $conn->prepare("SELECT * FROM productinfo WHERE id = ?");
$stmt->bind_param("i", $_POST['id']);
$stmt->execute();
$meta = $stmt->result_metadata();
while ($field = $meta->fetch_field()) {
$params[] = &$row[$field->name];
}
call_user_func_array(array($stmt, 'bind_result'), $params);
while ($stmt->fetch()) {
foreach($row as $key => $val) {
$productinfo[$key] = $val;
}
}
$stmt->close();
echo json_encode($productinfo); /** WE WILL THROW THIS DATA BACK TO THE AJAX REQUEST **/
?>
Be mindful of your console log to look for errors when testing this.
here is the image of the output of the code given below
The code below displays a table with hide/show content.
i want to display the username below the "username" heading of the table and the content that appears on clicking the "+" button should appear below their respective headers like project_name should appear under PROJECT NAME,project_id should appear under PROJECT ID and so on...
if anyone could help...
<?php
$hostname_ckumbh = "localhost";
$database_ckumbh = "pmb_demo";
$username_ckumbh = "root";
$password_ckumbh = "";
$ckumbh = mysql_pconnect($hostname_ckumbh , $username_ckumbh , $password_ckumbh) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_ckumbh , $ckumbh);
?>
<html>
<head>
<style>
.button1 {
width: 100%
}.wid25{width:25% !important;float:left}
.sign_cls {
cursor: pointer;
width: 10%;
background: #09F;
font-weight: bold;
color: #FFF
}
.sign_cls2 {
cursor: pointer;
width: 10%;
background: #900;
font-weight: bold;
color: #FFF
}
.sign_cls,.sign_cls2 {float: left; width: 1% !important;}
.date_cls {
width: 90%;
}
.wid_25 {
width: 25%;
float: left;
margin: 10px 0
}
.line_style td {
width: 25%
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">
function toggle(cls,cls2){
if($("."+cls).is(":visible")){
$("."+cls).hide("slow");
$("#"+cls2).removeClass('sign_cls2').addClass('sign_cls');
}else{
$("."+cls).show("slow");
$("#"+cls2).removeClass('sign_cls').addClass('sign_cls2');
}
}
</script>
</head>
<body>
<table border="0%" align="center" width="100%" height="100%" >
<tr class="line_style" align="center">
</br>
<td>User Name</td>
<td>Project Name</td>
<td>Project ID</td>
<td>Task Details</td>
<td>Status</td>
</tr>
<?php
$record =mysql_query("SELECT `u_vemail` FROM `proj_user`");
$i = 0;
while($row=mysql_fetch_array($record))
{
$record2 =mysql_query("SELECT `project_name` , `project_id` , `task_details` , `date` , `status` FROM `add_tasks` WHERE `user_name`='$row[u_vemail]'");
?>
<tr align="center">
<td colspan="4">
<div class="button1" onClick="toggle('hide<?php echo $i;?>','test<?php echo $i;?>')" style="float:left">
<span id="test<?php echo $i;?>" class="sign_cls">+</span><span class="date_cls"><?php echo $row["u_vemail"] ?></span>
</div>
<div class="hide<?php echo $i;?>" style="display:none;width:100%;float:left;">
<?php
while($row2 =mysql_fetch_array($record2))
{
?>
<div style="width:100%">
<div class="wid_25"><?php echo $row2["project_name"]; ?></div>
<div class="wid_25"><?php echo $row2["project_id"]; ?></div>
<div class="wid_25"><?php echo $row2["task_details"]; ?></div>
<div class="wid_25"><?php echo $row2["status"]; ?></div>
</div>
<?php
}
?></div>
</td>
</tr><?php
$i++;
}
?> <table>
</table>
</td>
</tr>
</table>
<br/>
<br/>
</body>
</html>
Just an initial question: can you see everything showing up on your screen? It sounds like you've got everything working and are just looking for a way to implement this show/hide function. Also, it looks like you've already attempted this with your toggle function although I'm not entirely sure where your variables cls and cls2 are coming from...
I tried something similar to get certain components to fade onto the screen with Javascript and CSS and what worked best for me what to add styling to the individual rows of a table and then apply a new style with javascript (i.e. make the style hidden and change it to visible with JS)
Here is what I mean...
#tableRow1 {opacity: 0;
transition: opacity 4s;
-webkit-transition: 4s;
transition-delay: 1s;
-webkit-transition-delay: 1s;}
#tableRow2 {opacity: 0;
transition: opacity 4s;
-webkit-transition: 4s;
transition-delay: 1s;
-webkit-transition-delay: 1s;}
#tableRow3 {opacity: 0;
transition: opacity 4s;
-webkit-transition: 4s;
transition-delay: 1s;
-webkit-transition-delay: 1s;}
<tr id='tableRow2' width="0%">
<tr id='tableRow2' width="0%">
<tr id='tableRow2' width="0%">
And the JS:
function loadPage(){
document.getElementById("tableRow1").style.opacity = 1;
document.getElementById("tableRow2").style.opacity = 1;
document.getElementById("tableRow3").style.opacity = 1;
}
I used opacity, but the concept would be the same for hidden. You can call the JS function with your button and if you are creating multiple buttons, you can give each button a unique id with a loop and put a loop in the function so that it makes the appropriate row visible. This should also work with div tags as long as they have a unique id. Hopefully this helps...
To appear username below username, Project name below project name you can try this code:
<tr class="line_style" align="center">
<th>User Name</th>
<th>Project Name</th>
<th>Project ID</th>
<th>Task Details</th>
<th>Status</th>
</tr>
<tr align="center">
<td colspan="4">
<div class="button1" onClick="toggle('hide<?php echo $i;?>','test<?php echo $i;?>')" style="float:left">
<span id="test<?php echo $i;?>" class="sign_cls">+</span><span class="date_cls"><?php echo $row["u_vemail"] ?></span>
</div>
<div class="hide<?php echo $i;?>" style="display:none;width:100%;float:left;">
<?php
while($row2 =mysql_fetch_array($record2))
{
?>
<div style="width:100%">
<div class="wid_25"><?php echo $row2["project_name"]; ?></div>
<div class="wid_25"><?php echo $row2["project_id"]; ?></div>
<div class="wid_25"><?php echo $row2["task_details"]; ?></div>
<div class="wid_25"><?php echo $row2["status"]; ?></div>
</div>
<?php
}
?>
</div>
</td>
</tr>
The problem is you used (<td></td>) instead of (<th></th>) tag.
Hope it will help you........
<?php
$hostname_ckumbh = "localhost";
$database_ckumbh = "pmb_demo";
$username_ckumbh = "root";
$password_ckumbh = "";
$ckumbh = mysql_pconnect($hostname_ckumbh, $username_ckumbh, $password_ckumbh) or trigger_error(mysql_error(), E_USER_ERROR);
mysql_select_db($database_ckumbh, $ckumbh);
?>
<html>
<head>
<style>
.button1 {
width: 100%
}.wid25{width:25% !important;float:left}
.sign_cls {
cursor: pointer;
width: 10%;
background: #09F;
font-weight: bold;
color: #FFF
}
.sign_cls2 {
cursor: pointer;
width: 10%;
background: #900;
font-weight: bold;
color: #FFF
}
.sign_cls,.sign_cls2 {float: left; width: 1% !important;}
.date_cls {
width: 90%;
}
.wid_25 {
width: 25%;
float: left;
margin: 10px 0
}
.line_style td {
width: 25%
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">
function toggle(cls, cls2) {
if ($("." + cls).is(":visible")) {
$("." + cls).hide("slow");
$("#" + cls2).removeClass('sign_cls2').addClass('sign_cls');
} else {
$("." + cls).show("slow");
$("#" + cls2).removeClass('sign_cls').addClass('sign_cls2');
}
}
</script>
</head>
<body>
<table border="1" align="center" width="100%" height="100%" >
<tr>
<td></td>
<td>User Name</td>
<td>Project Name</td>
<td>Project ID</td>
<td>Task Details</td>
<td>Status</td>
</tr>
<?php
$record =mysql_query("SELECT `u_vemail` FROM `proj_user`");
//$record = array('0', '1'); // push your sql result to this array
$i = 0;
while ($row=mysql_fetch_array($record)) {
//$row2 = array("project_name", "project_id", "task_details", "status"); // push your sql result to this array
$record2 =mysql_query("SELECT `project_name` , `project_id` , `task_details` , `date` , `status` FROM `add_tasks` WHERE `user_name`='$row[u_vemail]'");
$row2 =mysql_fetch_array($record2);
?>
<tr align="center">
<td><span onclick="hideRow('ex<?php echo $i?>','id<?php echo $i?>')" id="id<?php echo $i?>">+</span></td>
<td class="ex<?php echo $i?>"><?php echo $row["u_vemail"] ?></td>
<td class="ex<?php echo $i?>"><?php echo $row2["project_name"]; ?></td>
<td class="ex<?php echo $i?>"><?php echo $row2["project_id"]; ?></td>
<td class="ex<?php echo $i?>"><?php echo $row2["task_details"]; ?></td>
<td class="ex<?php echo $i?>"><?php echo $row2["status"]; ?></td>
</tr>
<?php
$i++;
}
?>
</table>
<script>
function hideRow(id1,id2){
$("."+id1).toggle();
if(document.getElementsByClassName(id1)[0].style.display == 'none'){
$("#"+id2).css("background-color","red");
}else{
$("#"+id2).css("background-color","white");
}
}
</script>
</body>
</html>
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
i want to store data in a session so that i could use it on the next page.
Here is my code where the radio buttons are used.
<link rel="stylesheet" type="text/css" href="payout.css"/>
<font face='calibri'>
<?php
session_start();
$conn = #mysql_connect("localhost","root","");
$db = #mysql_select_db("");
include("includes/functions.php");
mysql_set_charset("UTF8");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Billing Info</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script language="javascript">
$(document).ready(function () {
$("#center input[value='COD']").click(function () {
if (this.checked) {
$("#centerdown input[value='COD']").prop("checked", true);
} // end if checked
});
}); // end doc ready
$(document).ready(function () {
$("#center input[value='PickUp']").click(function () {
if (this.checked) {
$("#centerdown input[value='PickUp']").prop("checked", true);
} // end if checked
});
}); // end doc ready
$(document).ready(function () {
$("#center input[value='LBC']").click(function () {
if (this.checked) {
$("#centerdown input[value='BPI']").prop("checked", true);
} // end if checked
});
}); // end doc ready
</script>
<style>
#price{
color:red;
font-size:20px;
padding-right: 10px;
font-family: "Times New Roman", Times, serif;
float:right;
}
td{
display:block;
}
</style>
</head>
<body>
<input type="hidden" name="command" />
<div align="center">
<table border="0" cellpadding="2px">
<tr><td><table border="0" cellpadding="5px" cellspacing="1px" style="font-family:Verdana, Geneva, sans-serif; font-size:11px; background-color:#E1E1E1" width="500px">
<?php
if(is_array($_SESSION['cart'])){
echo '<tr bgcolor="#FFFFFF" style="font-weight:bold"><td></td><td>Name</td><td>Price</td><td>Qty</td><td>Amount</td></tr>';
$max=count($_SESSION['cart']);
for($i=0;$i<$max;$i++){
$pid=$_SESSION['cart'][$i]['productid'];
$q=$_SESSION['cart'][$i]['qty'];
$pname=get_product_prod_name($pid);
if($q==0) continue;
?>
<tr bgcolor="#FFFFFF"><td><?php echo $i+1?></td><td><?php echo $pname?></td>
<td>₱<?php echo number_format(get_prod_price($pid),2)?></td>
<td><input type="text" name="product<?php echo $pid?>" value="<?php echo $q?>" maxlength="2" size="2" disabled/></td>
<td>₱<?php echo number_format((get_prod_price($pid)*$q),2)?></td>
</tr>
<?php
}
?>
<tr><td></td><td colspan="5" align='right'><b>Order Total: ₱<?php echo get_order_total()?></b></td></tr>
<?php
}
else{
echo "<tr bgColor='#FFFFFF'><td>There are no items in your shopping cart!</td>";
}
?>
</table></td>
</tr>
</table>
<center><h1>Shipping Method</h1></center>
<form method="post">
<table width="900" border="0" align="center" cellpadding="2" cellspacing="0" id='center'>
<tr>
<td><input type="radio" name="carrier" <?php if (isset($carrier) && $carrier=="LBC") echo "checked";?> value="LBC"></td>
<td><img src="../paymentoptions/LBC.jpg" alt="LBC" class="picture"/></td>
<td><p>The Shipping takes 1-2 days for NCR and 2-3 days for any provincial.<p>
<!--<div id='price'> Additional ₱250 </div></td>-->
</tr>
<tr>
<td><input type="radio" name="carrier" <?php if (isset($carrier) && $carrier=="PickUp") echo "checked";?> value="PickUp"></td>
<td><img src="../paymentoptions/Pick-up.jpg" alt="Pick-Up" class="picture"/></td>
<td><p>Office hours: 10:00 am to 5:00 pm<p>
<!--<div id='price'> Free!! </div></td>-->
</tr>
</table>
<br>
<br>
<center><h1>Payment Method</h1></center>
<table width="900" border="0" align="center" cellpadding="2" cellspacing="0" id='centerdown'>
<tr>
<td><input type="radio" disabled name="payment" <?php if (isset($payment) && $payment=="BPI") echo "checked";?> value="BPI"></td>
<td><img src="../paymentoptions/BPI.jpg"></td>
<td><p>Pay by BPI bank deposit (we need confirmation of payment through email.)<p></td>
</tr>
<tr>
<td><input type="radio" disabled name="payment" <?php if (isset($payment) && $payment=="PickUp") echo "checked";?> value="PickUp"></td>
<td><img src="../paymentoptions/Pick-up.jpg"></td>
<td><p>Pick up. You have 5 days reservation period. You pay for the merchandise upon pick-up<p></td>
</tr>
</table>
<table>
<tr><td><input type="button" value="View Shopping Cart" onclick="window.location='shoppingcart.php?'"></td><td><input type="button" name="order" value="Place Order" onclick="window.location='billing.php?'"/> <!--<input type="button" value="Confirm Order" onclick="window.location='quotation.php?'">--></td></tr>
</table>
</form>
<?php
if (isset($_POST['order'])){
$_SESSION['carrier'] = $carrier;
$_SESSION['payment'] = $payment;
}
?>
</div>
</body>
</html>
I think what i placed at the bottom are wrong. haha. I have no idea how to do it, Thanks for looking!
These variables should be stored now in session memory.
These will be available on any page a session is started, until overwritten or destroyed, or by browser closing/timing out.
You can call them:
$somthing = $_SESSION['carrier'];
or how ever you need to use them.
<input name='blah' value='<?php echo $_SESSION['carrier'];?>'>
I have a form which is not submitted in IE. I just want to hide image upload button (file type) and show a custom browse button. My file upload has display none. when i click on the label i call the file click event and choose a file. but when i submit the page it does not submit it, No error message in console. it is working fine in firefox.
Here is my code.
<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="robots" content="index, follow" />
<title>New world of interaction</title>
<script>
function checkFields()
{
var fup = document.getElementById('authenticationimage');
var fileName = fup.value;
var ext = fileName.substring(fileName.lastIndexOf('.') + 1);
if(ext == "jpg" || ext == "JPG")
{
return true;
}
else
{
alert("Upload Jpeg image only");
document.getElementById('imagename').innerHTML = '';
return false;
}
}
function readURL() {
var fup = document.getElementById('authenticationimage');
var fileName = fup.value;
document.getElementById('imagename').innerHTML = fileName;
}
function removeimage() {
document.getElementById('imagename').innerHTML = '';
}
</script>
</head>
<body>
<table border="0" cellpadding="10" cellspacing="10" width="100%" align="center">
<form action="test.php" method="post" enctype="multipart/form-data" onsubmit="return checkFields();">
<tr>
<td width="25%" style="padding-left:15px"><strong>Image</strong></td>
<td width="75%">
<table border="0">
<tr><td style="border:1px solid #596166;"><label id="imagename" style="width:200px;display:inline-block;"></label></td>
<td>
<div class="ImageUpload">
<label for="authenticationimage" onclick="document.getElementById('authenticationimage').click();">
<img src="browse.png" alt="Browse" style="width:60px;cursor: pointer;"/>
</label>
<input id="authenticationimage" name="authenticationimage" type="file" onchange="readURL()" style="display:none"/>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td></td>
<td height="20"><input type="submit" name="submit" value="submit" />
<input type="reset" name="reset" onclick="removeimage();" value="reset">
</td>
</tr>
</form>
</table>
</body>
</html>
It is done by using css property
.select-wrapper {
background: url('templates/ncrcorp/images/upload.png') no-repeat;
background-size: cover;
display: block;
position: relative;
width: 60px;
height: 24px;
}
#authenticationimage {
width: 60px;
height: 24px;
opacity: 0;
cursor: pointer;
filter: alpha(opacity=0); /* IE 5-7 */
}
and
<span class="select-wrapper">
<input id="authenticationimage" name="authenticationimage" type="file" onchange="readURL()" />
</span>
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I just build Centos 6.4 in my HP Server, i use PHP 5.3.3 , Apache 2.2.15, Mysql 5.1.69.
When i want to login always fail, the source code as a follow :
index.php
<?
include "functions.php";
start_session();
session_destroy();
start_session();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Please Login First</title>
<link href="Tampilan/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="Tampilan/css/validationEngine.jquery.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="Tampilan/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="Tampilan/js/jquery.validationEngine.js" ></script>
<script type="text/javascript" src="Tampilan/js/jquery.validationEngine-en.js" ></script>
<style type="text/css">
.myTableStyle {
position: absolute;
top: 45%;
left: 37%;
}
#full-screen-background-image {
z-index: -999;
width: 100%;
height: auto;
position: fixed;
top: 0;
left: 0;
}
#wrapper {
position: relative;
width: 800px;
min-height: 400px;
margin: 100px auto;
color: #333;
}
.overlay-text {
position: absolute;
top: 20px;
left: 225px;
font-size: 38.5px;
font-weight: bold;
color: #ddd;
font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
}
</style>
<script src="content/md5.js"></script>
<script>
function cek()
{
if(!document.form1.username.value)
{
document.form1.username.focus();
window.alert("Please Fill In The Username");
}
else if(!document.form1.password.value)
{
document.form1.password.focus();
window.alert("Please Fill In The Password");
}
else {
document.form2.username.value=document.form1.username.value;
document.form2.password.value=calcMD5(document.form1.password.value);
document.form2.submit();
}
}
</script>
<link href="style.css" rel="stylesheet" type="text/css">
<link href="bootstrap.min.css" rel="stylesheet" type="text/css">
<noscript>
<div class="pagetitle">This page cannot be loaded properly because your browser has been set to deny the usage of Javascript. Please enable the Javascript support at your browser in order to continue</div>
<meta http-equiv="Refresh" content="0;noscript.php"/>
</noscript>
</head>
<div class="all-page">
<div class="page-header">
<!--<img alt="image" src="Tampilan/img/Stema1.jpg" style="height: 300px;width: 100%;z-index: -1;"/>!-->
<p class="overlay-text">
SIS Admission
</p>
<body onload="document.form1.username.focus()">
<form name="form1" action="javascript:cek()">
<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
<tr>
<td width="100%" valign="middle" align="center">
<table border="0" align="center" width="300" cellpadding="0" cellspacing="0">
<tr>
<td align="center" colspan="2" height="50"><div class="medTitle">Please Login</div></td>
</tr>
<tr>
<td align="center" width="120" height="30"><div class="smallTitle">Username </div></td>
<td align="left"><input type="text" name="username" class="input"/></td>
</tr>
<tr>
<td align="center" height="30"><div class="smallTitle">Password </div></td>
<td align="left"><input type="password" class="input" name="password"/></td>
</tr>
<tr>
<td align="center" colspan="2" height="40"><input type="submit" class="button" value="Login"/></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<form name="form2" action="login.php" method="post">
<input type="hidden" name="username"/>
<input type="hidden" name="password"/>
<input type="hidden" name="sess" value="<?=session_id();?>"/>
</form>
<div class="well navbar navbar-fixed-bottom">
<center>
Copyright © 2013 Saint John's Catholic School Developed by IT Department Of Saint John's Catholic School. All Rights Reserved.
</center>
</div>
</body>
</html>
login.php
<?
include "functions.php";
if(!isset($_POST['username'])||!isset($_POST['password'])||!isset($_POST['sess'])){
?>
<script>
alert("Silahkan masukan username/password anda");
location.href="index.php";
</script>
<?
}
else
{
session_start();
$session_id=$_POST['sess'];
if($session_id!=session_id()){
?>
<script>
alert("Untuk dapat menggunakan website ini, browser anda haruslah menerima cookie yang diberikan");
location.href="index.php";
</script>
<?
}
else{
$username=$_POST['username'];
$password=$_POST['password'];
connect_local();
$pola_password="^[a-zA-Z0-9]{1,}$";
$pola_username="^[a-zA-Z0-9_]{1,}$";
if(!ereg($pola_username,$username)){
?>
<script>
alert("Silahkan masukan username");
location.href="index.php";
</script>
<?
}
else if(!ereg($pola_password,$password)){
?>
<script>
alert("Silahkan masukan password");
location.href="index.php";
</script>
<?
}
else{
$query="select * from ms_user where username='$username' and password='$password'";
$result=mysql_query($query);
if(mysql_num_rows($result)>1) {
?>
<script>
alert("Username/password tidak terdaftar");
location.href="index.php";
</script>
<?
}
else if(mysql_num_rows($result)==1){
$hasil=mysql_fetch_array($result);
if($hasil['status']==0){
?>
<script>
alert("Username/password tidak terdaftar");
location.href="index.php";
</script>
<?
}
else{
$username=$hasil['username'];
$id_ms_user=$hasil['id_ms_user'];
$status=$hasil['status'];
$_SESSION['ses_username']=$username;
$_SESSION['ses_user_id']=$id_ms_user;
$_SESSION['ses_access_level']=$status;
header("location:main.php");
}
}
else {
?>
<script>
alert("Username/password tidak terdaftar");
location.href="index.php";
</script>
<?
}
}
}
}
?>
I don't have problem like this before when i use PHP 5.1.6, Apache 2.2.3 and Mysql 5.0.24a.
what are you using that code
start_session();
session_destroy();
start_session();
remove all of these and replace it with
session_start();
if($_SESSION['ses_username'] == "")
{
session_destroy();
}
Replace
start_session();
by-
session_start();
its session_start() NOT start_session()
or you can use in index.php
<?
include "functions.php";
if(!isset($_SESSION))
{
session_start();
}
if($_SESSION['ses_username'] == '')
{
session_destroy();
}
?>