|
Please how can I use $_SERVER['PHP_SELF'] code to save record and print
simultaneouly using PHP. I need the data been submitted into the database to print on the POS printer. See form action used below. Please assist.
<form method="post" name="form1" action="<?php echo $editFormAction; ?> target="_parent">
|
|
|
|
|
Hi guys
Im struggling with something small. i am watching tutorials on PHP and MYSQL but since the video and now SQL syntax changed.
please check my query if the syntax is correct, it worked fine until i inserted my variable $uh.... not sure if im missing quotes or something.
any help will be appreciated.
Unhealthy
Healthy
';
}
}
}
}
?>
|
|
|
|
|
Your question is meanwhile 10 days old but this might still help.
Quote: i am watching tutorials on PHP and MYSQL but since the video and now SQL syntax changed Don't use videos for learning programming. Most of them are of poor quality and some are telling you even wrong. Use books or web tutorials and read the official documentation for the used languages and functions (PHP: PHP Manual - Manual[^] and the documentation of the used database).
$uh=strtolower($_GET['uh']);
if($uh=='u'||$uh=='h'){ Never use == for string comparison. Use === or PHP: strcmp - Manual[^] to check for identity to avoid type juggling (see PHP: Comparison Operators - Manual[^]).
Always check for error return values and print error messages. This is especially useful with mysqli functions during development because you will get meaningful database error messages that help you finding syntax error in SQL query strings:
if ($result=mysqli_query($link, $sql)) {
if (mysqli_num_rows($result)) {
}
else {
echo 'no results';
}
}
else {
printf("SQL error: %s\n", mysqli_error($link));
}
Because $uh is a string and the healthy_unhealthy field probably too or a single character, you should enclose the value in single quotes in the query string:
$sql = "SELECT food,calories FROM food WHERE healthy_unhealthy = '". $uh . '" ORDER by id";
|
|
|
|
|
You should also escape variable
$_GET - security...
|
|
|
|
|
i am working on php and want to add accordian on every row in that dyanamic data is there but as i add accordian it always showing at tne end of all the rows
|
|
|
|
|
With ?php echo $editFormAction/ $_SERVER['PHP_SELF'] as form action, how can I access the data entered in a form textbox but not submitted into db from another pop up window
|
|
|
|
|
Let us assume that we have the following form.
<?php
echo '<form name="signUpForm1" method="POST" action="'.$_SERVER["PHP_SELF"].'">";
<input name="field1" type="textbox"></input> <?php /* lets say field1 value is "John" */
<input name="field2" type="textbox"></input> /* Lets say field2 value is "Doe" */
</form>
?>
and you wish to use the values from signUpForm1 in signUpForm2. much like below
<form name="signUpForm2">
<?php echo "Welcome ".$_POST[field1]." ".$_POST[field2];
$Username=$_POST[field1]." ".$_POST[field2];
?>
<input type="textbox" name="User Name" value="<?php echo $Username;?>">
While I admit there may be some syntax errors with double and/single quotes, it should basically demonstrate the basic idea.
Just a note, if you use method="GET" then use
$_GET['field1'] or
$_GET['field2']
|
|
|
|
|
Hello,I am new developer which uses php codeigniter. I got barcode generator code in core php but didn't able to convert that code into php codeigniter. So please help me .about it.
|
|
|
|
|
You can use composer and https://github.com/picqer/php-barcode-generator
|
|
|
|
|
I need to print a form data on another page. But the page been referenced opened a normal window. I want the window to appear in a smaller dimension to enable me print result to a POS printer.
This is the code I used on the onCLick Button attributes. Please any idea will be appreciated. Thanks
|
|
|
|
|
I have a form that submits data into my MySql database using the
php $_SERVER['PHP_SELF']
But I want to be able to view the contents of the data entered prior to submission on another page. Using this code
<input type= button name="Print receipt" onClick=window.open("print_process_script.php","width=550,height=300,left=150,top=200,toolbar=0,") value="Print Reciept" />
It opens another page but does not show the data entered just the Caption for the textbox only.
Please assist.
|
|
|
|
|
Please I need help on how to use 4 digit format as incremental value using PHP. the cod below I used displays incremetally but it only in 1,2,3 instead of 001,002,003.
What is wrong with m code?
$query = "Select Max(Serial_Number) From captain_order";
$returnD = mysql_query($query);
$result = mysql_fetch_assoc($returnD);
Print mysql_error();
$maxRows = $result['Max(Serial_Number)'];
if(empty($maxRows)){
$lastRow = $maxRows = 1;
}else{
$lastRow = $maxRows + 0001 ;
}
|
|
|
|
|
Computers don't know about leading zeroes. That is just a form of representing numbers to humans (being shown on screen, printed, or even written on a piece of paper).
So just use
$lastRow = $maxRows + 1; If you want to show the number with leading zeroes, use a corresponding formatting function like PHP: sprintf - Manual[^]:
echo sprintf("%03d", $lastRow);
|
|
|
|
|
|
How to use PHP global processing script action to process sumbitted data and display form data entered on the text on another page . Please provide an easy way out of this. Thanks
|
|
|
|
|
|
Please I need a guide on how to use a php $_SERVER['PHP_SELF'] to insert form data into Mysql database and redisplay data entered on another form.
My form action is <pre><form method="post" name="form1" action="<?php echo $editFormAction; ?>
While the print button should be able to open another page with contents of the main form on it. I used this
<input name="Print receipt" type= "button" onclick = "Openform();" value="Print reciept" /></td> Please assist
|
|
|
|
|
So I'm building a website and I've got alot of the core functionality sorted. Been trying to make a register and login system. Everything on the front end works ok. Registering is fine but I can't get the password_verify function to recognise a correct password.
So here's the registration part:
$res = $conn->query("SELECT * FROM `users` WHERE `email`= '$email'");
if (mysqli_num_rows($res) != 0) {
echo "<br> Sorry this email already is registered with us!!! <br>";
$start = microtime(true);
do {
$stop = microtime(true);
} while ($stop - $start < 5);
header("location: index.php");
}
else {
$cost = 8;
$target_time = 0.05;
do {
$start = microtime(true);
$password = password_hash( $password, PASSWORD_BCRYPT, ["cost" => $cost] );
$stop = microtime(true);
$cost++;
} while ($stop - $start < $target_time);
$date = date("Y-m-d ");
$sql="INSERT INTO `users` (`username`, `email`, `password`, `sign_up_date`)
VALUES ('$username', '$email', '$password', '$date')";
if ($conn->query($sql)) {
echo "Registration Successful!!!";
header( "location: index.php" );
}
}
That's just the part where a hash is generated and stored on an SQL database. Now here's the login part:
$conn = new mysqli( "localhost", $user, $pass, $db ) or die("Unable to connect");
$email = mysqli_real_escape_string($conn, $_POST['email']);
$res = $conn->query("SELECT * FROM `users` WHERE `email`= '$email'");
if (mysqli_num_rows($res) == false) {
echo "Sorry no such user exists :(";
}
else {
$user = $res->fetch_assoc();
if ( password_verify( $_POST['password'], $user['password']) ) {
echo " Password login accepted. Redirecting...";
$_SESSION['username'] = $user['username'];
$_SESSION['email'] = $user['email'];
$_SESSION['logged_in'] = true;
header("location: testFront.php");
}
else {
echo "<br>Sorry Wrong Password!!!<br>";
}
}
For some reason the password_verify keeps returning false and I have no idea why. Have I overlooked something in the code. Is it my fundamental understanding of hashes?
Thanks
|
|
|
|
|
I am creating a platform where users sends requests using forms(in a database) to the admin and the admin should reply them when he has finished the job.
Can anyone help me on how to make the admin view form by form and reply to its specific sender.
|
|
|
|
|
Hello
I'm doing a survey web where I keep my questions in a database and then I call them when the user selects which survey will answer and my questions are shown.
This is my code where I show my questions and add raddiobuttons and textareas.
<pre><table>
<tr>
<!--
<td colspan="2"> <h3><?php echo $titulo; ?></h3></td>
<input type="hidden" name="id" value="<?php echo $id; ?>">
</tr>
<?php
$sql = "SELECT texto,id FROM respuestas WHERE idenc='$id'";
$sql = mysqli_query($conexion,$sql);
while ($row = mysqli_fetch_array($sql)){
$texto = $row["texto"];
$idres = $row["id"];
?>
<tr>
<!--
<td width="50"><?php echo $idres; ?></td>
<td width="470"><?php echo $texto; ?></td>
<td> SI <input type="radio" name="radio<?php echo $idres; ?>" value="SI"></td>
<td> NO <input type="radio" name="radio<?php echo $idres; ?>" value="NO"></td>
<td><textarea name="comentarios<?php echo $idres; ?>" rows="5" cols="20">Escribe aquí tus Hallazgos</textarea></td>
<td><textarea name="acciones<?php echo $idres; ?>" rows="5" cols="20">Escribe aquí tus Acciones Correctivas</textarea></td>
</tr>
<?php } ?>
and here I want to save the answers
<pre><?php
$respuesta = $_POST["radio$idres"];
$comentarios = $_POST["comentarios$idres"];
$acciones = $_POST["acciones$idres"];
require 'conexion.php';
$fecha_actual = date("y-m-d");
if(!empty($respuesta)){
$sql = "INSERT INTO opciones(ID, idenc, valor, Accion, hallazgo, fecha) VALUES ('$respuesta' ,'$comentarios' ,'$acciones' ,'$fecha_actual')";
$sql = mysqli_query($conexion,$sql);
}
header("Location: verEncuesta.php");
?>
I just do not know how to save the questions by id question and id survey. I suppose it's a cycle but I do not know how to structure that cycle
|
|
|
|
|
Hai,
<!DOCTYPE html>
<html >
<head>
<style type="text/css">
.centerDiv
{
width: 1000px;
height:600px;
margin: 0 auto;
}
.div1
{
width: 500px;
height:600px;
float:left;
}
.div2
{
width: 500px;
height:600px;
float:left;
}
</style>
</head>
<body>
<div class="centerDiv">
<div class="div1">
<object type="text/html" data="https://Somewebsite.com" width="500px" height="600px" style="inline-block:auto;border:5px ridge blue">
</object>
</div>
<div class="div2">
<object type="text/html" data="https://Somewebsite.com" width="500px" height="600px" style="inline-block:auto;border:5px ridge blue">
</object>
</div>
</div>
</body>
</html>
this is a html code I created. when this page is loaded. the two links in the 'div' will also be loaded. In the original link page there will be a username and password to enter. the user will manually enter this username and password and submit it. then a new page will be loaded which will display the current temperature of two sites. what I need is get that temperature value and load it to a MySQL database. this is my problem. what I plan is to get the html of the loaded link. and search for the element temperature and get the temperature value. but I don't know how to grasp the HTML code of the link.
Can Any one help me to grasp the html of link site using php or any other methods!!
Please help.
|
|
|
|
|
|
Thank you for your reply. but how can i get the url from div?
after entering the username and password. url in the div will be changed because a new page will be loaded.
Please help!
|
|
|
|
|
You wrote
Quote: this is a html code I created so I thought that you know the URLs and just want to load them to get the temperatures.
If you want to load a page from a login form, you have to pass the URL with parameters as send by the form when submitting. If this works depends on the form (how the the login parameters are passed). If it is not your site, it is probably intended by the site owner that you can't automate the process. Then you can only ask him if he provides an API to do such.
|
|
|
|
|
https://somewebsite.com/
this site is null
|
|
|
|