PHP - These Two Extensions To Work Together
I want these two extensions to work together Note that the plugin has 2 codes 1 https://wordpress.org/plugins/qty-increment-buttons-for-woocommerce/ 2 https://wordpress.org/plugins/woo-product-price-x-quantity-preview/#installation Similar TutorialsBy default, PHP comes with some extensions disabled. Question 1: Is there a command (via command-line) to enable ALL extensions? Question 2: Are there any drawbacks to having all extensions enabled (e.g. slows it down, conflicts, etc.)? Thank you.
How do I only allow jpg and png file extensions to be uploaded as a attachment. My current code is below $msg = ''; if (array_key_exists('userfile', $_FILES)) { // create object of PHPMailer class with boolean parameter which sets/unsets exception. $mail = new PHPMailer(true); try { //$mail->isSMTP(); // using SMTP protocol $mail->Host = 'host'; // SMTP host as gmail $mail->SMTPAuth = true; // enable smtp authentication $mail->Username = 'emailaddress'; // sender gmail host $mail->Password = 'emailpassword'; // sender gmail host password $mail->SMTPSecure = 'ssl'; // for encrypted connection $mail->Port = 587; // port for SMTP $mail->setFrom('emailaddress', "Name"); // sender's email and name $mail->addAddress('emailaddress', "Name"); // receiver's email and name $attachmentNames = []; //Attach multiple files one by one for ($ct = 0; $ct < count($_FILES['userfile']['tmp_name']); $ct++) { $uploadfile = tempnam(sys_get_temp_dir(), hash('sha256', $_FILES['userfile']['name'][$ct])); $filename = $_FILES['userfile']['name'][$ct]; if (move_uploaded_file($_FILES['userfile']['tmp_name'][$ct], $uploadfile)) { if(isset($uploadfile)) $mail->addAttachment($uploadfile, $filename); $attachmentNames[] = $_FILES['userfile']['name'][$ct]; } else { $msg .= 'Failed to move file to ' . $uploadfile; } }
Hello
So I want to try and match everything preceding a file extension in a string using preg_match.
An example file name: "Images_home_blah.blah.jpg" .
I've tried the following regex:
/^([a-z0-9_\-\.]+)(?!\.jpg)/iBut this sadly appears to capture the whole string instead of ignoring the '.jpg' part. Can anyone point me in the right direction? Thanks, Drongo Hi. I'm making a file-sharing website but how do I stop users from uploading certain extensions? Here is my script so far: <?php session_start(); $file_name = $HTTP_POST_FILES['ufile']['name'];$random_digit=rand(0000,9999);$new_file_name=$random_digit.$file_name;$path= "upload/".$new_file_name;if($ufile !=none){if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)){echo "Successful<BR/>";}else{echo "Error";}}?>() Hello one and all, Just a quick request here, I've written a script that sends an email with an attached file by the user. (docx, txt, pdf, doc, rtf) are the formats I have accepted. At the moment I'm sending them with the following... Code: [Select] $fileatt_type = "application/pdf"; // File Type It works fine with all formats in older email clients, i.e, like yahoo before they updated the layout, but in the newer versions it's specific and if I try to send it this way it is always delivered as a .PDF and doesn't open if it is any of the other formats. It may sound silly but I've searched a fair bit for the other extensions or formats to include instead of the above code (maybe something like application/doc or something) but there doesn't seem to be a list. Can anyone point me in the right direction? Much obliged, PHP the learned. How would I go about making it to where,, I can tell the script to use a certain extension of php in the script like curl.. ? Thanks This one requires lots of up front information: I have a page, for this example that I will call page.php. It takes get parameters, and for this example I'll call the parameter "step". So I have a URL like this: page.php?step=1 This page has a form with an action of page.php?step=1. The code on the page validates the posting information. If the information is bad, it returns the user to page.php?step=1; if it is good, it takes the user to page.php?step=2 via header( "location:page.php?step=2" ). So redirection is done by relative path, not full URLs. This all works as expected. Now what I've done is set .htaccess to be HTTPS for this page, via this code: # Turn SSL on for payments RewriteCond %{HTTPS} off RewriteCond %{SCRIPT_FILENAME} \/page\.php [NC] RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] This works (initially). However, once you try to post the form, it just redirects back to the step=1 version of the page. I really don't know how or why that would be. I'm not sure how else I can explain this or what other information you may have. But it's frustrating to not get a page working in HTTPS that works in HTTP. Very odd. Any suggestions? (I don't even really know the best location to figure out when/why it's redirecting back to the original page.) Hi.., I use below method to export data to excel. header('Content-type: application/ms-excel'); header('Content-Disposition: attachment; filename=abc.xls'); if I run the script from the server. (http://localhost/export.php) it is work. (pop-up window if i want save or open the file) but if i run the script from the client (http://192.168.1.5/export.php) it is not work. (nothing happen) any idea how to solve this? require_once 'includes/upload.class.php'; $upload = new uploads(); $details = $upload->getFileInformation($id); <?php echo $details['upload_desc']; ?> then here the class. require_once 'db.class.php'; class uploads extends database { private $uploadData; function uploadFile() { public function getFileInformation($id) { $this->uploadData = $this->readData("uploadfiles", "upload_id", $id); return $this->uploadData; } But it wont work! Some of you may have seen one of my many posts about email issues. Some users don't get them, and I have determined it is probably because we are marked as spam.
We are a service that grades sales team members on their phone skills. Listening to pre-recorded calls, grading and uploading them to our site, and then another part of our business looks them over and sometimes leaves a message that then get's forwarded to this persons work email.
I have determined there is ways to get marked as spam as default by not having an opt out link. This is not an option, these sales members employer has opted in, and the emails are going to work related accounts hosted at that employer. Also, if one of these staff members is not so bright, or disgruntled they may mark us as spam anyways. The bottom line is that we have very little control over whether we are or are not marked as spam.
So we want to start looking into sending text messages and this is where I start to question how good of an idea this is.
First off, if it was me, and the messages where being sent to a device that my employer did not provide, I would in no way want work related text messages coming to me. Unless there is a vested interest in getting them. IE, I'm the boss at this place and am always on the clock. What if you are on the bottom? It's just a job for you.
What if it is a pre-paid device, text messages cost money. What then? What if they don't even have, or want a cell phone?
The short of it is this. If I'm at a job that is just another job, and this employer tells me that I have to get these messages. I'm going to look for another job. I see the organizations having continuous issues and complaints from their employees. Thus us as a business having issues keeping clients.
What am I getting into here? What are your opinions on this matter? What are your recommendations as to alerting users of something on our site that we can rest assured are being received 100% of the time?
Thanks!
Nick
i need help trying to get this delete feature to work its not deleting from the database (by the way i took out my database names and passwords at the top of the file) is it possible someone could help me, ive been working on this for like a week and cant figure out the problem. thanks! you can email me at spr_spng@yahoo.com picture 2.png is showing what it looks like Code: [Select] <?php $host="localhost"; // Host name $username="username"; // Mysql username $password="password"; // Mysql password $db_name="database_name"; // Database name $tbl_name="table_name"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <style> /*table affects look of the whole table look */ table { margin-left: auto; margin-right: auto; border: 1px solid #330000; border-collapse:collapse; width:70%; border-width: 5px 5px 5px 5px; border-spacing: 1px; border-style: outset outset outset outset; border-color: #330000 #330000 #330000 #330000; border-collapse: separate; background-color: #330000; #800517 f535aa #330000 school color #9A0000 school color2 #991B1E school color3 #CCCC99 school color4 #9A0000 } /*th is table header */ th { text-align: left; height: 2.5em; background-color: #330000; color: #FC0; font-size:1.5em; } /*td is table data or the cells below the header*/ td { text-align: left; height:1.0em; font-size:1.0em; vertical-align:bottom; padding:10px; border-width: 5px 5px 5px 5px; padding: 8px 8px 8px 8px; border-style: outset outset outset outset; border-color: #9A0000 #9A0000 #9A0000 #9A0000; background-color: #CCCC99; -moz-border-radius: 0px 0px 0px 0px; } </style> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Pick Which Rows you want to delete, Then press delete.</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> <td align="center" bgcolor="#FFFFFF">delete</td></tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['email']; ?></td> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <? // Check if delete button active, start this // edited if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">"; } } mysql_close(); ?> </table> </form> </td> </tr> </table> Hi there, As the question says i tried several things but i can't work it out and my knowledge about php isn't that well. Hi I am having trouble with a login code which keeps producing a true value even when the password is incorrect. Just spent 4 hours writing code and I think I've gone a bit coo coo: Code: [Select] <h1>Login</h1> <p>If you are an existing member please login below. If you are new to this site please register to obtain your unqiue login and password by <a href="register.php">clicking here.</a></p> <?php require_once('common.php'); $error = '0'; if (isset($_POST['login'])){ // Get user input $username = isset($_POST['username']) ? $_POST['username'] : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; // Try to login the user $error = loginUser($username,$password); } ?> <?php if ($error != '') {?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="loginform"> <table width="100%"> <tr><td>Username:</td><td> <input name="username" type="text" /></td></tr> <tr><td>Password:</td><td> <input name="password" type="password" /></td></tr> <tr><td colspan="2" align="center"><input type="submit" name="login" value="Login" /></td></tr> </table> </form> <a href="register.php">Register</a> <?php } if (isset($_POST['login'])){ ?> <table width="100%"><tr><td><br/> <?php if ($error == '') { echo "<h1>Welcome $username! <br/>You are logged in!</h1><br/><br/>"; echo '<a href="browse_index.php"><h2>Now you can start shopping! ---CLICK HERE---</h2></a>'; } else echo $error; ?> <br/><br/><br/></td></tr></table> <?php } ?> Code for Common.php: ?php function loginUser($user,$pass){ $errorText = ''; $validUser = false; // Check user existance $pfile = fopen("users.txt","r"); rewind($pfile); //$counter=0; while (!feof($pfile)) { $line = fgets($pfile); $temp = explode(':', $line); if ($temp[5] == $user) { // User exists, check password if (trim($data[0]) == trim(md5($pass))){ $validUser= true; $_SESSION['userName'] = $user; //$counter = $counter + 1; //echo $data; } break; } } fclose($pfile); if ($validUser != false) $errorText = "Invalid username or password!"; if ($validUser == true) $_SESSION['validUser'] = true; else $_SESSION['validUser'] = false; return $errorText; } function logoutUser(){ unset($_SESSION['validUser']); unset($_SESSION['userName']); } function checkUser(){ if ((!isset($_SESSION['validUser'])) || ($_SESSION['validUser'] != true)){ header('Location: login.php'); } } ?> I'm sorry if this maybe is an obvious understanding for you, but i can't understand one thing with URL's. If i create my page called "index.php" and put it in a folder called "folder" then the URL in the address bar would be: http://www.website.com/folder/index.php But then i deside to add a few more pages with like next and previous links to scroll through them. I put those pages in a folder called "pages" within the folder "folder". Now the URL's would something look like this! http://www.website.com/folder/pages/page1.php http://www.website.com/folder/pages/page2.php etc... Thats the only way i know URL's are created and look like. But now too my question.. This is a few URL's i've seen on a site and every URL leeds to a new page but there is no slashes indicating new folders? How do you do that? Here is some examples of how the URL's could look like: http://www.website.com/index.php http://www.website.com/index.php?p=new http://www.website.com/index.php?p=new&page=121 http://www.website.com/merge.php http://www.website.com/merge.php?id=20381 And every URL was a comnpletly new page? Hi everybody *asian accent*, im trying to figure out how to display xml in php i know how to do things like <condition> <conditionId>4000</conditionId> <conditionDisplayName>Very Good</conditionDisplayName> </condition> for each blah blah as $item $condition = $item->condition->conditionId echo $condition; BUT........how do i get these values in XML to display in php this <searchResult count="2"> I want to get the value of count to display help please So I wanted to use a \ in order to stop PHP from registering my quotes. For some reason it does not seem to work. I am running PHP version 5.3.8. What am I doing wrong? All i get is a link to view all partners. What I want to see is all the people in the database and how many comments each has. Anyone? Was on last night but still couldn't get it woking Code: [Select] <?php $db = mysql_connect('--', '--', '-!'); if (!$db) { die('Could not connect: ' . mysql_error()); } mysql_select_db ('-',$db); $max_items = 5; function displayPartners($all = 0){ global $db, $max_items; if ($all == 0){ $query = "SELECT id,title, DATE_FORMAT(postdate, '%Y-%m-%d') as date FROM partners ORDER BY postdate DESC LIMIT $max_items"; }else{ $query = "SELECT id,title, DATE_FORMAT(postdate, '%Y-%m-%d') as date FROM partners ORDER BY postdate DESC"; } if (!$db) while ($row = mysql_fetch_assoc($result)){ echo "<TABLE border = \"1\" width=\"300\>\n"; $date = $row['date']; $title = htmlentities ($row['title']); echo "<TR><TD><b>$title</b>posted on $date</TD></TR>\n"; echo "<TR><TD>$partners</TD></TR>\n"; $comment_query = "SELECT count(*) FROM comment WHERE partners_id ={$row['id']}"; $comment_result = mysql_query ($comment_query); $comment_row = mysql_fetch_row($comment_result); echo "<TR><TD><ahref=\"{$_SERVER['PHP_SELF']}" . "?action = show&id={$row['id']}\<Comments</a>($comment_row[0]}</TD></TR>\n)"; echo "</TABLE>\n"; echo "<BR>\n"; } if ($all == 0){ echo "<a href =\"{$_SERVER['PHP_SELF']}?action=all\">View all Partners</a>\n"; } } function displayOneItem($id){ global $db; $query = 'SELECT * FROM partners WHERE id = $id'; $result = mysql_query ($query); if (mysql_num_rows ($result) == 0){ echo 'No partners found '; return; } $row = mysql_fetch_assoc($result); echo "<TABLE border =\"1\" width=\"300\>\n"; $title = htmlentities ($row['title']); echo "<TR><TD><b>$title</b></TD></TR>\n"; echo "<TR><TD>$partners<b>/TD></TR>\n"; echo "</TABLE>\n"; echo "<BR>\n"; displayComments($id); } function displayComments($id){ global $db; $query = "SELECT * FROM comment WHERE partners_id=$id"; $result = mysql_query ($query); echo "Comments:<BR><HRwidth=\"300\">\n"; while ($row = mysql_fetch_assoc ($result)){ echo "<TABLE border=\"1\"width=\"300\">\n"; $name = htmlentities ($row['name']); echo "<TR><TD><b>by:$name</b></TD></TR>\n"; $comment = strip_tags ($row['comment'],'<a><b><i><u>'); $comment = nl2br ($comment); echo "<TR><TD>$comment</TD></TR>\n"; echo "</TABLE>\n"; echo "<BR>\n"; } echo "<HR width=\"300\">"; echo "<FORM action=\"{$_SERVER['PHP_SELF']}" . "?action=addcomment&id=$id\"method=POST>\n"; echo "Name: <input type=\"text\" " . "width=\"30\"name=\"name\"><BR>\n"; echo "<TEXTAREA cols=\"40\" rows=\"5\" " . "name=\"comment\"></TEXTAREA><BR>\n"; echo "<input type=\"submit\"name=\"submit\" " ."value=\"Add Comment\"\n"; echo "</FORM>\n"; } function addComment($id) { global $db; $query = "INSERT INTO comment " . "VALUES('',$id,'{$_POST['name']}'," . "'{$_POST['comment']}')"; mysql_query ($query); echo "Comment submitted<BR>\n"; echo "<a href=\"{$_SERVER['PHP_SELF']}" . "?action=show&id=$id\">Back</a>\n"; } echo "<CENTER>\n"; switch($_GET['action']) { case 'show': displayOneItem($_GET['id']); break; case 'all': displayPartners(1); break; case 'addcomment': addComment($GET['id']); break; default: displayPartners(); } ?> Code: [Select] <?php $path = "www.DOMAINHERE.com/images/showlogos/".$showNAME."_logo.jpg"; if (file_exists($path)){ echo "YES"; ?> <a href="index.php"><img src="/images/showlogos/<?=$showNAME?>_logo.jpg" width="190" height="62" /></a><br /><br /> <?php } else { echo "NO!"; echo $path; } ?> the result is echoing out NO! which means the file doesnt exist... however when i c+p the echo'd $path into my address bar, it shows the image.. Thanks So, I have part of this snippet of code in my homepage and it pops up an inner window notification that briefly displays and then goes away...I'm looking to do it for a non-index.php page and it just isnt working. In the index.php page, it automatically occurs when the form loads and in this case, I need to invoke it...any help would be awesome..
It is the section where I'm echoing the JS script that isn't working.
<?php if($_GET){ if(isset($_GET['add'])){ /* Attempt MySQL server connection. Assuming you are running MySQL server with default setting (user 'root' with no password) */ $link = mysqli_connect("localhost", "root", "test", "vendors"); // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } $name = mysqli_real_escape_string($link, $_REQUEST['vendor']); $company = mysqli_real_escape_string($link, $_REQUEST['company']); $type = mysqli_real_escape_string($link, $_REQUEST['type']); $email = mysqli_real_escape_string($link, $_REQUEST['email']); $soc = mysqli_real_escape_string($link, $_REQUEST['soc']); $status = mysqli_real_escape_string($link, $_REQUEST['status']); // Attempt insert query execution $sql = "INSERT INTO vendor_data (name, company, type, email, soc, status) VALUES ('$name', '$company', '$type', '$email', '$soc', '$status')"; if(mysqli_query($link, $sql)){ echo ' <script type="text/javascript"> $(document).ready(function(){ demo.initChartist(); $.notify({ icon: "pe-7s-gift", message: "TESTING!" },{ type: "info", timer: 4000 }); }); </script>'; } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } // Close connection mysqli_close($link); } } ?> <!doctype html>
hi all, i have been struckling with this code of mine i want when i click a link to change the setting for the menu (see code) Code: [Select] <? echo "[".$_SESSION['menu']."]"; ?> <table class="border_test"> <tr> <td valign="top" align="left"> <!-- menu items: menu --> <img src="../design/item.png" width="10" height="10"><a href="<?=$_SERVER['REQUEST_URI'];?>" onclick="<? $_SESSION['menu']=1;?>"><b> Site menu:</b></a> </td> </tr> <? if($_SESSION['menu']==1) { echo ' <tr> <td> <img src="../design/subitem.png" width="10" height="10"> <a href="?topic=add_menu">Toevoegen menu item.</a><br> <img src="../design/subitem.png" width="10" height="10"> <a href="?topic=edit_menu">Bewerken menu item.</a><br> <img src="../design/subitem.png" width="10" height="10"> <a href="?topic=del_menu">Verwijderen menu item.</a> </td> </tr>'; } ?> <tr> <td> <!-- menu items: submenu --> <img src="../design/item.png" width="10" height="10"><a href="<?=$_SERVER['REQUEST_URI'];?>" onclick="<? $_SESSION['menu']=2;?>"><b> Site submenu:</b></a> </td> </tr> <? if($_SESSION['menu']==2) { echo ' <tr> <td> <img src="../design/subitem.png" width="10" height="10"> <a href="?topic=add_submenu">Toevoegen submenu item.</a><br> <img src="../design/subitem.png" width="10" height="10"> <a href="?topic=edit_submenu">Bewerken submenu item.</a><br> <img src="../design/subitem.png" width="10" height="10"> <a href="?topic=del_submenu">Verwijderen submenu item.</a> </td> </tr>'; } ?> <tr> <td> <!-- menu items: Pagina's --> <img src="../design/item.png" width="10" height="10"><a href="<?=$_SERVER['REQUEST_URI']; ?>"><b> Pagina's:</b></a> </td> </tr> </table> so what it wil do is show the subitem list of the main menu item when de var is changed! butt when i use it it always set to the last ( in this case to: 2 ) even when i click the first link to set it to 1 can somebody help me to get it to work? thnx, |