PHP

119K

Solutions

33K

Contributors

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi Experts

Could you point a way to code a multichoices combo by using "Smarty" PHP library?

Thanks in advance!
0
Cloud Class® Course: Microsoft Windows 7 Basic
LVL 12
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

I was told to make a simple check in and check out for volunteers, they walk in pick their name from dropdown click submit and it inserts them and time into mysql db, i am having problems with the checkout part. the process is the same as check in, you pick your name from dropdown of users logged in and click checkout and it captures your id and time, this is where i am getting stuck at especially the sql query to do this i only have part of it. Any guidance will be appreciated. Thank You.
0
I had this question after viewing PayPal IPN, PHP, & MySQL.

Hi,

I am selling CDs (and other stuff) mainly via eBay but also in other outlets (BigCommerce shop) and I want to do that following to automate this:
1. Collect payment notifications via Paypal IPN message using an IPN Listener Script and verify the payment - this bit has been tested as ok
2. Add CD/DVD sales information to a MySQL Database - I've created the database and attempted to add some lines to index.php to create entries
3. Transpose (parse) the resulting table information so that this can then be sent to Kunaki to ship the discs - I have found and partially updated a php file for this that does connect with Kunaki
4. As Kunaki is somewhat slow to send to anywhere but the USA, I wish to provide a link to a download for the software contained on the discs, immediately, so the buyer has instant access (currently, I've been doing this bit manually as I have access to the files on my home Synology NAS drive and have been sharing the links via email - I am eager to automate this somehow)
5. If I could also update the sale by providing a USPS tracking number that Kunaki provide, to the customer somehow, that would be great
6. Also, if I could update eBay or Paypal to state that the item has been sent, that would also be ideal.

So far, I have 3 files:

ipnlistener.php - to interface with the Paypal IPN
0
mb_convert_encoding($row['french_text'], 'UTF-8', 'ISO-8859-1')

I am using the function above to make sure all my database generated text that have french accents don't get the accents encoded into garbage.. and it works great. The only problem is that is stripping out all my apostrophes.

How do I modify it so it will not remove my apostrophes?
0
Hi,

Im having an issue with this code in the command line:
sed -i 's/row['email']/_SESSION['nen']/g' /var/www/v2-stage/v2-stage/add_on/change_password.php

Open in new window


For some reason i think it isnt working since the 'email'
but that is how the code is & i cant change it.
Also im running it through the shell_exec for php. but i tried it directly and it wasnt working as well.

any ideas?
0
Hello guys I'm having trouble sending data via aJax post to other page.
my code explain it all how might it supposedly works.

I want to send data from test.php to page.php while page document loads and dispaly also page.php to test.php if it really works.
To make it short how can I echo data:{tablename:tablename} to page.php

Here is my code
test.php
<?php
include ('include/head.php');
?>
<html>
<body>
<div class"showme" id="showme"></div>
</body>
</html>
<script>
$(document).ready(function(){
var tablename = "tbl_released";
{
	$.ajax
				({
					url:'page.php',
					method:'POST',
					data:{tablename:tablename},
					success:function(data){
					
					 }    
				});
				$("#showme").load("page.php");
			}
});
</script>

Open in new window

page.php
<?php
if(isset($_POST["tablename"])){
echo $_POST["tablename"];
}
?>
<html>
<body>
<h1>I am page.php</h1>
</body>
</html>

Open in new window

0
Hi, I am populating a table using php. How can I get the value of 'JOB' from the table where the user clicks the checkbox. I have tried to add a class like previously suggested, but I cannot make it work.  I am attaching my code

while($row = $result->fetch_assoc()) {
        printf("<tr><id='traba'><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td><input class='boxtocheck' type='checkbox' id='editar' name='editar' value='".e."' ><td></tr>",$row["fecha"], $row["job"],$row["tipo"],$row["valor"],$row["dinero"],$row["editar"]);
        $total=$total+$row["valor"];
        $total2=$total2+$row["dinero"];
        $jobs=$jobs+1;
    }
} else {
    echo "0 results";
}

Open in new window



<script>    
$(document).ready(function()
{
$('.boxtocheck').change(function() 
  {
    if(this.checked === true)
    {
// I am trying to see if the correct value is posted        y1 = document.getElementById('traba').value;
//                                                                                           console.log(y1);
         alert('Load page to edit');
    }
  });   
});    
</script>

Open in new window

0
This is a follow on to this question - https://www.experts-exchange.com/questions/29107724/Need-Category-Sorted-By-Product-Not-First-Letter.html#acceptAnswerByMember

Need to have category page sorted by product and within by description.  Putting $off, %off, buy x.  With the x amount being in an ascending sequence.

For example, Buy 4 then Buy 5 then Buy 9 etc.
0
Hi, I'm having trouble with PHP aJax post method. it gives me n error... Here i my code, by the way this is a server side proccesing..
aJax
$(document).on('click', '.view_data', function(){  
           var id = $(this).attr("id");  
           if(id != '')  
           {  
                $.ajax({  
                     url:"repselect.php",  
                     method:"POST",  
                     data:{id:id},  
                     success:function(data){  
                          $('#repair_detail').html(data);  
                          $('#viewModal').modal('show');  
                     }  
                });  
           }            
      }); 

Open in new window

fetch.php
<?php
include('include/db.php');
if(isset($_POST["id"]))
{
$sth = $connection -> prepare ("SELECT * FROM tbl_released WHERE id = :id");
$sth -> execute();
$row = $sth -> fetch();
{
	echo $row["branch"];
}
}
?>

Open in new window

fire button
<button type="button" name="view" id="'.$row["id"].'" class="btn btn-success btn-xs view_data">View</button>

Open in new window

error message
Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in D:\web\htdocs\web\repselect.php on line 6

Open in new window

the question is how can i get the id to post on fetch page and view details according to its ID




Sorry I just solve it...

Here is the working code
<?php
include('include/db.php');
if(isset($_POST["id"]))
{
$sth = 

Open in new window

0
Hello! I'm trying to make my first web application of a hotel(this is an education project not a payed one) and I have a lot of issues...The most important one is that if a user at the registration process selects that he wants to reserve 4 rooms he needs to make the checkin process 4 times, once for each room. I have succesfully managed to register the user and login, but the problem is with showing the check-in form for a number of times... I managed to show it once, but the second time it doesn't work, it shows me the details for the same room, not for a different one, or it makes an infinite loop...what can I do? Here it's the PHP code:
<?php
	ob_start();
	 $success = false;
	// Errors reporting, used if needed
	error_reporting(E_ALL);
	ini_set('display_errors', 'on');

	// General configuration like base, used if needed
	include_once ('include/config.inc.php');

	// Mail functions
	include_once ('include/mail.functions.php');



	// DBConn
	include_once ('class/DB/DBConn.includeall.php');
	$db = new DBConn(NULL);

	// Includere clasa login
	require_once ('class/class_login.php');

	// Set up current language
	$lang = "ro";
	$_SESSION[PRE.'lang'] = $lang;
	$row='';
	$access = 0;
	$user = (isset($_POST['nume']) && !empty($_POST['nume'])) ? $_POST['nume'] : "" ;
	$email = (isset($_POST['email']) && !empty($_POST['email'])) ? $_POST['email'] : "" ;
	$telefon = (isset($_POST['telefon']) && !empty($_POST['telefon'])) ? $_POST['telefon'] : "" ;
	$cnp = 

Open in new window

0
Cloud Class® Course: C++ 11 Fundamentals
LVL 12
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

I am trying to select a value from dropdown list and insert into mysql database, i am new to PHP and i know my code is not pretty but i want to learn, please steer me in the right direction. Thank You.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>

<body>

<form method="post" action="">
 
 <label >Please Select Username</label>
 
 <select name="checkin">
<?php
 require('db.php'); 

$sql = mysqli_query($con, "SELECT * FROM users LEFT JOIN check_in_out on users.id = check_in_out.check_id WHERE check_in_out.check_id IS NULL");
while ($row = $sql->fetch_assoc()){
echo "<option value=\"checkin\">" . $row['id'] . "</option>";
}

 ?>

</select>

 <button type="submit" name="submit" >Submit</button>
 


<?php
 require('db.php'); 
if(isset($_POST["submit"]))
{
 
$check_id ='check_id';
$check_in_date = date("Y-m-d H:i:s");
$sql =  "INSERT INTO check_in_out (check_id,check_in_date) VALUES ('$check_id','$check_in_date')"; 
$result = mysqli_query($con,$sql);

    echo "You are checked in";
}

 ?>
  </form> 
</body>
</html>

Open in new window

0
I have a php page and am trying to set the focus to a specific text input box when the page opens using this mechanism:

<script type="text/javascript" language="JavaScript">
	function jsSetFocus(){
		document.forms["OrderDetail"]["ProdnOrder"].disabled = true;
		document.forms["OrderDetail"]["VECode"].focus();
	}
	jsSetFocus();

Open in new window


my problem is that the focus event only fires intermittently - the ProdnOrder input is disabled but the focus is on the path in the address box which is highlighted. but occasionally the focus event works as it should.

How can I force the focus onto the VECode input box everytime?
0
How to write php output to excel? more than 100 rows and each 10 column. Platform linux.
0
Ajax Success callback doesn't work.
Hello this is my second question i have problem with success callback of my ajax function... it doesn't reload my data table after deleting rows... how can I correct it my code is
<script>
        $(document).on('click', '.delete', function() {
            var that = this;
            swal({
                title: "Are you sure?",
                text: "You will not be able to recover this imaginary file!",
                type: "warning",
                buttons: true,
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "Yes, delete it!",
                closeOnConfirm: false
            }).then(function(yes) {
                if (yes) {
                    var id = $(that).attr("id");
                    $.ajax({
                        url: "delete.php",
                        method: "POST",
                        data: {id: id},
                        success: function (data) {
                        dataTable.ajax.reload();
                        }
                    });
                }
                else {
                    return false;
                }
            })
        });
    </script>

Open in new window

my success code
                        success: function (data) {
                        dataTable.ajax.reload();
                        }

Open in new window

How Can I correct this guys?
0
Hello! I'm a newbie in programming and my first project it's an checkin system for a hotel. The system it's looking like this: first of all, the user will enter his name, check-in, check-out date,  the numbers of rooms that he wants to rent, number of people that will stay in a room, and the email address(all this done in the register.php page). After he'll enter this details, an email will be sent to him where he'll have a reservation number and the details about his reservation. After this, he'll go on an page(login.php) where he'll enter this reservation code and start the check-in process for each room, for example if he choosed 2 rooms, he'll make first the checkin for the first room then for the second(this should be done in the checkin.php page).If the checkin process was never made, it will start, otherwise an message will be shown that will say that the code was used or it's incorrect, it depends. What I want help it's with the login process and the starting of the checkin, I managed to send that email, generate that code but I can't login and start the checkin... I want to use only PostgreSQL, not MYSQL. Here it's the login.php:
<?php

	ob_start();
	 $error = false;
	// Errors reporting, used if needed
	error_reporting(E_ALL);
	ini_set('display_errors', 'on');

	// General configuration like base, used if needed
	include_once ('include/config.inc.php');

	// Mail functions
	include_once ('include/mail.functions.php');

	// Start session if needed
	

Open in new window

0
To activate some paid themes or plugins for websites (cms), buyers need a code. Otherwise the addons are not activated. I'm interested by this functionnality, but i have no idea where to start. Can someone point me in the right direction ? I have some addons and also websites for demo purpose, but i need to protect them. This kind of addons i'm talking about, need a code only once. Then the addon/website or whatever is accessible for everyone.
 I'm using php/css/html/javascript. The passcode/key protection i'm looking for is used by plugins and graphic themes sellers. To ensure the buyer has paid the addon and/or don't use it more than once. The target cms are wordpress, joomla, magento ...
Thank you.
X. Lin
0
I am trying to use PhpMailer to send email.
From GetHub i did download all package. For minimal installation i am using only class.phpmailer.php and class.SMTP.php. And also PHPMailerAutoload.php. Where i have next function :
function PHPMailerAutoload($classname)
{
    //Can't use __DIR__ as it's only in PHP 5.3+
    $filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
    if (is_readable($filename)) {
        require $filename;
    }
}

Open in new window


The first error that I am getting is :
 Connection failed. Error #2: stream_socket_client() [<a href='function.stream-socket-client'>function.stream-socket-client</a>]: php_network_getaddresses: getaddrinfo failed: Name or service not known

I have all files in same directory as main.php.
In my main.php i did change only lines with comments.  

What do I have to change to get rid of before mentioned error?

main.php:
<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
//use PHPMailer\PHPMailer\PHPMailer;
//use PHPMailer\PHPMailer\Exception;

//Load Composer's autoloader
require 'PHPMailerAutoload.php';

$mail = new PHPMailer(true);                            
try {
    //Server settings
    $mail->SMTPDebug = 4;                                               //ERRORS INFO
    $mail->isSMTP();                                     
    $mail->Host = 'smtp1.gmail.com'                          //   SMTP 

Open in new window

0
Hi,

im curious if there is a way to do the following in PHP but within a stored procedure with SQL on the fly

$managers = array(
	0 => array(
		"id"	=> 1,
		"name"  => "manager",
		"email"	=> "email"
	)
	...
)

foreach($managers AS $d){
	//send mail
	mail(...);
	
	//Insert into messages table
	INSERT INTO...

}

Open in new window


Essentially, i would want to SELECT the manager from a table and then immediately insert it a message into the massage table

for example:

1. select manager 1
2. insert message into message table for manager 1
3. repeat for manager 2
,...so on

I would handle sending the email using php

I KNOW i can do this in a few steps such as
1. Select all the managers and organize them into an array to loop over
2. loop over the managers and create an array of emails as well as sql statements i can create a transaction with and submit the inserts all at once
3. complete loop
4. send the transaction to sql
5. send the email

but i am curious if i can do it one for one within a stored procedure

Thanks in advance
0
I am trying to create a zip file using php ZipArchive; however, the files added have non-english characters in their names. I have tried using iconv and some other methods with no luck. Does anybody know how to solve this?

$zip            = new ZipArchive;        
$zip->open($filename,ZipArchive::CREATE|ZipArchive::OVERWRITE);
$zip->addFile($pathtomyfile,'Documento-nuÌmero-5.doc');
$zip->close();

Open in new window


I have tried with php 5.4 and php 7.2. By the way, all the names are utf-8 encoded.
0
Cloud Class® Course: Certified Penetration Testing
LVL 12
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

I'm new to mysql and need some help. I have populated a multi-select drop down with my first query. The dropdown populated correctly and I want to use the value or values from the dropdown to get results from a second query. I will try to explain some more.

I have a multi select dropdown named students that is populated with Names and values that are numbers. I want to select one, two or all and use those values in a second query. The dropdown will have values like 390, 234, 5421, 461. If you look at the query below you will see the student_id = 461 that value is what I want to get from the dropdown. This query works if I place in the student_id.

SELECT *, student_id, SUM(handled) FROM stats WHERE student_id = 461

From there I
echo "Handled: " . $row["SUM(handled)"]. "";
and that works just fine.

Thanks for any help.
0
Taking over an older website for someone I upgraded their backend db from SQL 2000 to 2016.  The web hosting server has not been modified, but now we are seeing a new error when trying to create a PDF report.  This worked before, so I don't think that suggestions I found online about cURL are accurate.  

"TCPDF ERROR: [Image] Unable to get image: ../../ban/main/ProductImages/HeaderImages/bbts_header.jpg"

Here's the entire content of Reports.php where I believe the issue is occurring.  I am not a PHP developer, but can typically support issues like this.  Please be specific with suggested solutions.  You  can search for header or logo to see the area where the issue most likely is occurring.  

<?php

require_once('../../tcpdf/config/lang/eng.php');
require_once('../../tcpdf/tcpdf.php');

class ReportsEntity extends Entity
{
    # Reports
    function getReportsList() {
        global $keyWebSubDomains;
        return NDatabase::getAllAssoc("SELECT convert(varchar(256),keyReport) as keyReport, title, stored_procedure, header_image, columns, execString FROM Reports WHERE

keyWebSubDomains = convert(uniqueidentifier,'$keyWebSubDomains') ORDER BY title");
    }
    function getReport($uid) {
#NDatabase::setDebug();        
        $report = NDatabase::getARow("SELECT convert(varchar(256),keyReport) as keyReport, title, stored_procedure, header_image, columns, execString FROM Reports WHERE

keyReport=convert(uniqueidentifier,'$uid')");
        return …
0
Hi,
I have wordpress site that we use to sent out emails to users about different stuffs, information etc..
Users instead of logging in and replying on the sites, replies directly from the mail server.
How can I set it up such that once the first email is sent, the email conversation between user and admins can happen on the email itself but the messages get recorded in the database with the appropriate reference /tags.
0
PHP Class Undefined Variable.  I asked this before and thought I had it, but I don't.

I am extending a class from a function in a plugin file to add custom functionality.  I am getting the PHP error :
Undefined variable: plugin_name
Undefined variable: version

What am I doing wrong?

My Code:
<?php
class tlg_CED_ETSY_Admin extends CED_ETSY_Admin {
    public function __construct( $plugin_name, $version ) 
	{
		$this->plugin_name = $plugin_name;
		$this->version = $version;
        }
    public function ced_etsy_render_metabox_sa() {
        global $post;
        $product_id = $post->ID;
        $product_name = $post->post_title;
        $sears_title = get_post_meta($product_id, '_ced_etsy_title', true);
        $long_description = get_post_meta($product_id, '_ced_etsy_long_description', true);
        $sku = get_post_meta($product_id, '_sku', true);
        $old_warehouse = get_the_term_list($post->ID, 'warehouse-item', '', ', ');
        $old_warehouse = strip_tags($old_warehouse);
        $simple_warehouse = get_post_meta($product_id, '_tlg_simple_product_location_field', true);
        $variable_warehouse = get_post_meta($product_id, '_warehouse_location_field', true);
        if (!empty($old_warehouse)) {
            $warehouse_local = $product_name . ' - ' . $old_warehouse . ' - ' . $sku;
        } elseif (!empty($simple_warehouse)) {

            $warehouse_local = $product_name . ' - ' . $simple_warehouse . ' - ' . $sku;
        } elseif 

Open in new window

0
I need an app based (session independent) counter that gives me the order of the queries that are done to server.
Does PDO (or MySQL) has an internal counter for that? If it does not have how a can I get the order of the queries without writing to db or using the file system.

What I do right now is
1. construct my PDO object  :
$dbpdo = new PDO("mysql:host=$db_host;dbname=$db_name", $db_username, $db_password, array(PDO::ATTR_PERSISTENT => true));
$dbpdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbpdo->setAttribute(PDO::ATTR_TIMEOUT, 30);
$dbpdo->query("SET NAMES utf8");  
      
2. Do the query:
$q = $dbpdo->prepare($sql);
$q-> execute($arr);

I need the order number of the query (app based)

Thank you
0
I have an html form.
I have the following php script.
 
The  saveVisit function below is one record.
I could have 1 or up to 6 records.

I am executing php with ajax.
How do I create the html form fields to allow for easy handling of dynamic records?
Also the same applies for my php to allow for dynamically handling record in server.



        function processEachVisit(){
            //loop through each visit

            //execute saveVisit query

        };



        //function to save each visit.
        function saveVisit($dbconn, $providerID, $clientId, $visitStart, $visitEnd, $visitUnits, $visitMinutes, $visitActvities, $visitComments){
            $Query = 'INSERT INTO serviceRendered (clientId, visitStart, visitEnd) VALUES
                      ( $1, $2, $3 ) RETURNING id';

            $result = pg_query_params($dbconn, $Query, array(clientId, visitStart, visitEnd));

            $row = pg_fetch_row($result);

            return $row['0'];

        }

Open in new window

0

PHP

119K

Solutions

33K

Contributors

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.