Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
when i'm trying to run my code i come across a blank site and i don't know how to fix it
i guess my calculations aren't working
here's the codes:
<html>
<head>
<meta charset="utf-8">
<title>Kalkulator spalania paliwa</title>
</head>
<body align="center">
<h1>Kalkulator spalania paliwa.</h1><br>
<form action="get_info.php" method="get">
Podaj spalone paliwo: <input type="text" name="sp"> l<br>
Podaj przejechaną odległość: <input type="text" name="km"> km<br>
<input type="submit">
</form>
</body>
and
<html>
<body>
<?php
function spalanie(){
$sp = $_GET["sp"];
$km = $_GET["km"];
$wynik = $sp * 100 / $km;
echo $wynik;
}
?>
</body>
You have defined the function but haven't called it. Call it like this below the function like
spalanie();
beacause your input tag has no value...
<input type="text" name="km" value="km">
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
<?php
session_start();
?>
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="pageContainer">
<form action="second.php" class="formLayout" method="post">
<div class="formGroup">
<label>Name:</label>
<input type="text" name="first_name"><br>
<input type="hidden" name="postback" value="true"><br>
</div>
<div class="formGroup">
<label> Car model:</label>
<div class="formElements">
<input type="radio" name="model" value="Mustang">Ford Mustang<br>
<input type="radio" name="model" value="Subaru">Subaru WRX STI<br>
<input type="radio" name="model" value="Corvette">Corvette<br>
</div>
<input type="submit" name="submit">
</form>
<?php
if (isset($_POST['submit'])) {
$_SESSION["first_name"] = $_POST["first_name"];
$_SESSION["model"] = $_POST["model"];
}
?>
</div>
</body>
</html>
I set up my code to set the value of the "first_name" and "model" names into my session variables.
When I try to access the values of the stored variables in the submission page of the form:
<?php
session_start();
?>
<html>
<body>
<?php
echo $_SESSION["first_name"];
echo $_SESSION["model"];
?>
</body>
</html>
I only receive the out of the model value, not the first_name value. I don't understand what I'm doing wrong here.
Let's assume your first file is called first.php. As shown in your <form>, the second one is second.php.
It seems that you are writing the data into the session in the first.php file, but this code will never run because you are submitting your form to second.php and not first.php!
So, move the code that writes the session variables into second.php instead. To test that it really worked, you can create a third.php to display them.
(I'm not sure why see the model set, but I guess it's still there from a previous test you did.)
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
this is my html code
<?php include('process.php') ?>
<!doctype html>
<html lang="en">
<head>
<title>Title</title>
</head>
<body>
<from action="index.php.php" method="post">
<?php include('errors.php'); ?>
<lable> name </lable>
<input type="text" name="name" placeholder="enter your name">
<lable>location</lable>
<input type="text" name="location" placeholder="enter your location">
<button type="submit" name="save_btn" >update</button>
</from>
</body>
</html>
this is my php code
<?php
session_start();
// initializing variables
$name="";
$location="";
// connect to the database
$db = mysqli_connect('localhost', 'newuser', 'password', 'curd');
// REGISTER USER
if (isset($_POST['save_btn'])) {
// receive all input values from the form
$name = mysqli_real_escape_string($db, $_POST['name']);
$location = mysqli_real_escape_string($db, $_POST['location']);
$query = "INSERT INTO data (name, location) VALUES('$name', '$location')";
mysqli_query($db, $query);
}
why its not store in data base? data base name correct and i have 3 tables
id (ai)
name (var 200)
location (var 200)
in my browser i can locate index.php but when i click button nothing happen any one can explain why its not working?
Fine, it seems that the problem is caused by 2 important typos:
<from action="index.php.php" method="post"> should be <form action="index.php" method="post">.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have php session not working in chrome and IE but working fine in Firefox.
I'm getting this error in page4.:
it show variable empty in page4, session not passing in page4 after the user click click me in page3
Notice: Undefined index: username in /var/www/html/phptest/test4.php on line 5
Please see my code and let me know where the error is.
Page2
<html>
<body>
<form action="test3.php" method="post">
Username: <br><input type="text" name="username"></br>
<input type="submit" name = 'submit1' value= 'Login'>
</form>
</body>
</html>
Page3
<html>
<body>
<?php
session_start();
$username = $_POST['username'];
$_SESSION['username']= $_POST['username'];
echo "<br> Hi $username.</br>";
?>
<form action="test4.php" method="post">
<input type="submit" name = 'submit' value= 'click me'>
</form>
</body>
</html>
Page 4
<?php
session_start();
$username = $_SESSION['username'];
echo "<br> Hi $username.</br>";
?>
session_start() must go at the top of the page before any output:
<?php
session_start();
?>
<html>
<body>
<?php
$username = $_POST['username'];
$_SESSION['username']= $_POST['username'];
echo "<br> Hi $username.</br>";
?>
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
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.
Improve this question
I am trying to distribute a value into 3 input fields so the sum of all 3 cannot exceed the set dynamic value. I tried it in JSFiddle it works fine. Here is the demo: http://jsfiddle.net/k2QVV/
Here is my code:
<!DOCTYPE html>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript">
var
total = parseInt($('#quantityRequired').text()),
inputs = $('input[type="number"]');
inputs
.attr('max', total)
.change(function() {
//Make sure that current value is in range
if($(this).val() > parseInt($(this).attr('max'))) {
$(this).val($(this).attr('max'));
} else if ($(this).val() < parseInt($(this).attr('min'))) {
$(this).val($(this).attr('min'));
}
//Get currently available total
var current = available();
//Now update max on each input
$('input').each(function(indx) {
$(this).attr('max', parseInt($(this).val()) + total - current);
});
});
</script>
</head>
<body>
Quantity Required : <span id='quantityRequired'>20</span><br />
<input type='number' name='val1' min='0' value='0' required /> <br />
<input type='number' name='val2' min='0' value='0' required /> <br />
<input type='number' name='val3' min='0' value='0' required />
</body>
</html>
Your code works on jsfiddle because the jQuery lib is loaded before your code is called.
You should load the library before calling your script, by adding this line:
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
right after:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
It throws me a syntax error, unexpected T_STRING, and I don't see anything wrong with it.
<div id="main">
<div id="wrap">
<?php
require("top.php");
$archpreg=fopen("p.txt", 'a+');
$archresp=fopen("r.txt", 'a+');
$preg=fread($archpreg,filesize("p.txt"));
$resp=fread($archresp,filesize("r.txt));
fclose($archpreg); fclose($archresp);
$listapreg= explode('###12', $preg); $listar= explode('###12', $resp);
for ($c=9; $c>=0; --$c){
$p=array_pop($listapreg);
$pp= explode ('###11',$p);
$nombre= $pp[1];
$apellido=$pp[2];
$foto= base64_decode ($pp[3]);
$id=$pp[0];
$pregunta= $pp[5];
$titulo= $pp[4];
for ($i=0; $i<count($listar); ++$i){
$r=$array_pop($listar);
$rr=explode ('###11',$r);
#if($rr[0]==$id){
# $nombre2=$rr[1];
# $apellido2=$rr[2];
# $respuesta=$rr[3];
#} ?>
<div>
<h4><?php echo $titulo?></h4>
<h5>Escrita por: <?php echo $nombre.' '.$apellido; >?> </h5>
<p>
<?php echo $pregunta ?>
<form method="get" action= "iresp.php">
<input type="submit" value="Responder!" id="responder"/>
<input type="hidden" name="id" value="aaa" />
</form>
</p>
<p>
<?php echo $respuesta ?>
</p>
</div>
<?php }
} ?>
</div>
</div>
</body>
</html>
The line $resp=fread($archresp,filesize("r.txt)); is missing a ", it should be $resp=fread($archresp,filesize("r.txt")); or better yet $resp=fread($archresp,filesize('r.txt')); since there is no variable substitution in the string.
$resp=fread($archresp,filesize("r.txt));
You have missed " sign ;)
You are missing some " in this line: $resp=fread($archresp,filesize("r.txt));
$resp=fread($archresp,filesize("r.txt));
There is a missing ". You should use an editor with syntax highlighting!