|
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
|
|
|
|
|
I'm trying to create a generic template for multiple pages by retrieving them in the database but it does not work. My database is properly enable at the top of my page.
function stmt_query2(){
$conn = pdo_con();
$query = '
SELECT * FROM layout_template as lt
INNER JOIN page_layout as pl ON lt.page_layout_id = pl.page_layout_id
WHERE pl.page_layout_id = 1';
$result = $heidisql->query($query);
return $result;
}
function item_detail() {
$output = '';
$result = stmt_query2();
while($rows = $result->fetch(PDO::FETCH_ASSOC)) {
$output .='<div class="row">';
$output .= '<div class="col-md-3">'
. '<a href="#"><img class="img-fluid rounded mb-3 mb-md-0" src="'.$rows["mainsub_layout_img"].'" alt="'.$rows["mainsub_layout_alt"].'"></a>'
. '</div>';
$output .= '<div class="col-md-5">';
$output .= '<h3>'.$rows["mainsub_layout_heading"].'</h3>';
$output .= '<p class="sub_description">'.$rows["mainsub_layout_txt"].'</p>';
$output .='<a class="btn btn-primary" href="#">Read More</a>';
$output .=' </div>'
. '</div>';
}
return $output;
}
But it work if I did it like that
$conn = pdo_con();
$query = '
SELECT * FROM layout_template as lt
INNER JOIN page_layout as pl ON lt.page_layout_id = pl.page_layout_id
WHERE pl.page_layout_id = 1';
$result = $heidisql->query($query);
while($rows = $result->fetch(PDO::FETCH_ASSOC)) {
$output .='<div class="row">';
$output .= '<div class="col-md-3">'
. '<a href="#"><img class="img-fluid rounded mb-3 mb-md-0" src="'.$rows["mainsub_layout_img"].'" alt="'.$rows["mainsub_layout_alt"].'"></a>'
. '</div>';
$output .= '<div class="col-md-5">';
$output .= '<h3>'.$rows["mainsub_layout_heading"].'</h3>';
$output .= '<p class="sub_description">'.$rows["mainsub_layout_txt"].'</p>';
$output .='<a class="btn btn-primary" href="#">Read More</a>';
$output .='</div></div>';
$output .='<hr>';
}
echo $output;
|
|
|
|
|
You probably have to call
$conn = pdo_con(); outside of the function.
|
|
|
|
|
The chat functionality is developed on a PHP platform and we are using ratchet as our framework. when its hosted on a server with no SSL installed its working as expected. when SSL is installed on the same server, the functionality is not working. The error in back-end is connection time out. We tried steps given in different discussions is stack overflow, no help. Seems challenging !! Roll eyes | Suggestions are most welcome, regarding the issue. Thanks in Advance.
|
|
|
|
|
I know nothing about php so no idea what you are specifically doing wrong...
However when a Client that IS using SSL attempts to connect to a server that is NOT using SSL then when the client attempts to connect a timeout exception will result.
That is because the client is sending specific requests to the server to set up the SSL protocol and the server does nothing with them - it does not respond. And when a client doesn't get a response it eventually times out.
So that is your problem.
Conversely if a client is NOT using SSL and the server IS using SSL then what happens, normally, is that the client will get a 'connection reset by peer' after a bit because the server is expecting the SSL protocol messages and they never arrive. So eventually (again normally) the server will give up and close the socket.
|
|
|
|
|
Good evening, I'm trying to implement access to our site using Facebook sdk (Ver. 5x PHP 5.6), I always get the following
error "Facebook SDK returned an error: No URL set!"
the code I use works fine in another test site (obviously with a different facebook app and secret keys), i really don't know where is the problem I post sources:
This is the index.php code where the button for the login and the call of SDK appears, for obvious security reasons I entered xxxx instead of the site name and other sensitive data.
require_once 'fbConfig.php';
require_once 'User.php';
if(isset($accessToken)){
if(isset($_SESSION['facebook_access_token'])){
$fb->setDefaultAccessToken($_SESSION['facebook_access_token']);
}else{
$_SESSION['facebook_access_token'] = (string) $accessToken;
$oAuth2Client = $fb->getOAuth2Client();
$longLivedAccessToken = $oAuth2Client->getLongLivedAccessToken($_SESSION['facebook_access_token']);
$_SESSION['facebook_access_token'] = (string) $longLivedAccessToken;
$fb->setDefaultAccessToken($_SESSION['facebook_access_token']);
}
if(isset($_GET['code'])){
header('Location: ./');
}
try {
$profileRequest = $fb->get('/me?fields=name,first_name,last_name,email,link,gen der,locale,picture');
$fbUserProfile = $profileRequest->getGraphNode()->asArray();
} catch(FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
session_destroy();
header("Location: ./");
exit;
} catch(FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$user = new User();
$fbUserData = array(
'oauth_provider'=> 'facebook',
'oauth_uid' => $fbUserProfile['id'],
'first_name' => $fbUserProfile['first_name'],
'last_name' => $fbUserProfile['last_name'],
'email' => $fbUserProfile['email'],
'gender' => $fbUserProfile['gender'],
'locale' => $fbUserProfile['locale'],
'picture' => $fbUserProfile['picture']['url'],
'link' => $fbUserProfile['link']
);
$userData = $user->checkUser($fbUserData);
$_SESSION['userData'] = $userData;
$logoutURL = $helper->getLogoutUrl($accessToken, $redirectURL.'logout.php');
if(!empty($userData)){
$output = "<h1>APP ID ".$appId ."</h1>";
$output .= '<h1>Facebook Profile Details </h1>';
$output .= '<img src="'.$userData['picture'].'">';
$output .= '<br/>Facebook ID : ' . $userData['oauth_uid'];
$output .= '<br/>Name : ' . $userData['first_name'].' '.$userData['last_name'];
$output .= '<br/>Email : ' . $userData['email'];
$output .= '<br/>Gender : ' . $userData['gender'];
$output .= '<br/>Locale : ' . $userData['locale'];
$output .= '<br/>Logged in with : Facebook';
$output .= '<br/><a href="'.$userData['link'].'" target="_blank">Click to Visit Facebook Page</a>';
$output .= '<br/>Logout from <a href="'.$logoutURL.'">Facebook</a>';
}else{
$output = '<h3 style="color:red">Some problem occurred, please try again.</h3>';
}
}else{
$loginURL = $helper->getLoginUrl($redirectURL, $fbPermissions);
$output = '<a href="'.htmlspecialchars($loginURL).'"><img src="images/fblogin-btn.png"></a>';
}
?>
<html>
<head>
<title>Login with Facebook using PHP by CodexWorld</title>
<style type="text/css">
h1{font-family:Arial, Helvetica, sans-serif;color:#999999;}
</style>
</head>
<body>
<!--
<div><?php echo $output; ?></div>
</body>
</html>
---------------- fbConfig.php -----------------
<pre lang="PHP">
error_reporting(E_ALL);
if(!session_id()){
session_start();
}
// Include the autoloader provided in the SDK
require_once __DIR__ . '/facebook-php-sdk/autoload.php';
// Include required libraries
use Facebook\Facebook;
use Facebook\Exceptions\FacebookResponseException;
use Facebook\Exceptions\FacebookSDKException;
/*
* Configuration and setup Facebook SDK
*/
$appId = '22xxxxxxxx'; //Facebook App ID
$appSecret = '50xxxxxx'; //Facebook App Secret
$redirectURL = 'http://xxxxx.altervista.org/fbapp0'; //Callback URL
$fbPermissions = array('email'); //Optional permissions
$fb = new Facebook(array(
'app_id' => $appId,
'app_secret' => $appSecret,
'default_graph_version' => 'v2.2',
));
// Get redirect login helper
$helper = $fb->getRedirectLoginHelper();
// Try to get access token
try {
if(isset($_SESSION['facebook_access_token'])){
$accessToken = $_SESSION['facebook_access_token'];
}else{
$accessToken = $helper->getAccessToken();
}
} catch(FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
In the facebook app configuration panel:
Valid OAuth redirect URIs
http://xxxx.altervista.org/ e http://xxxx.altervista.org/fbapp0/
Again, these two scripts copied with the sdk facebook folder on another site work fine, Thanks in advance for the answers, a greeting
|
|
|
|
|
Hi all. Not sure if someone here can help. I'm trying to pass an associative array from Javascript to PHP. I'm 99% certain the Javascript is ok since the callback function works, but here it is just in case:
var purchase, sendDB;
var purchase, sendDB;
sendDB = [{"item":"Boots", "price":"100"}, {"item":"Phone", "price":"800"}, {"item":"AK","price":"600"}];
console.log(sendDB[0].item);
$.post("POS_DB.php", sendDB, function(r){
alert("sending purchase data to php.");
});
However, the php doesn't quite want to accept/process that data. Here's the php code:
$url = 'http://localhost/POS_Proj/testFront.php';
$data = file_get_contents($url);
$p = json_decode($data, true);
print $p[0]->item;
echo $data;
modified 23-Oct-17 22:46pm.
|
|
|
|
|
|
How do I Attach acrobat pdf page which is download from the website that i worked on when i click manually and that pdf attach with send email in codeigniter from controller .MY question is how to send email every month on 1st date automatically to their company's user?
function download_report($serial)
{
$data['rm_data'] = $this->reports_model->get_cyclemachine($serial);
$data['report_data'] = $this->reports_model->get_cycledata($serial);
$data['solar'] = $this->reports_model->is_solar($serial);
$html=$this->load->view('report/rpt_report_data1',$data,true);
/*$this->load->library('m_pdf');
$m_pdf = $this->m_pdf->load();
$pdfFilePath ="/H:/file1.pdf"; //As PDF creation takes a bit of memory,we're saving the created file in downloads
$message=$m_pdf ->WriteHTML($html); //write the HTML into the PDF
$m_pdf ->Output($pdfFilePath, 'D'); */ // save to file because we can
$config = Array(
'protocol'=>'smtp',
'smtp_host'=>''//i have this hostname,user,and password
'smtp_user'=>'',
'smtp_pass'=>'',
'smtp_port'=>'25',
'validation'=>TRUE,
'charset'=>'utf-8',
'wordwrap'=> TRUE,
'mailtype'=>'html'
);
//$to_email= $this->reports_model->get_cyclemachine($serial);
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->set_crlf( "\r\n" );
$this->email->from('');//I have from
$this->email->to('');
$this->email->subject('report');
$this->email->message($html);
//$this->email->attach($html);
//$this->email->attach('/H:/file1.pdf');
if ($this->email->send())
{
echo 'Email send.';
}
else
{
show_error($this->email->print_debugger());
}
modified 17-Oct-17 10:45am.
|
|
|
|
|
Don't try to fit your entire question into the "Subject" box. Put a small summary of your question there, and provide the details in the "Message" box.
Also, format your code properly. Select the code block, and click the "code" button in the toolbar. If that doesn't work, put <pre>...</pre> tags around it.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|