Search the Community
Showing results for tags 'php'.
-
Hey there I've finally decided to give up on this, and ask the community some help... It has given me so many headaches Here are the basics : 1. A file is generated using PDFtk 2. An automated email is sent with the file attached I'm using postfix through an SMTP relay I've gathered some code around the internet and tried to learn to use it the best as I could and here's what I came up with : $to = $user['usr_mail']; $from = 'contact@mydomain.fr'; $fromName = 'Jonathan Bdlf Photographie '; if ($bc_type == 1){ // Si couple $subject = 'Votre bon cadeau pour une séance photo en couple '; } else if ($bc_type == 2){ // Si famille $subject = 'Votre bon cadeau pour une séance photo en famille '; } $prenom = $user['usr_prenom']; $html_content = "<h1>Voici votre bon cadeau </h1> <p>Je vous remercie pour votre achat</p>"; $plaintext = "Voici votre bon cadeau. Je vous remercie pour votre achat."; $boundary = uniqid(); // attachment $attachment = chunk_split(base64_encode(file_get_contents($outputPDF))); // message with attachment $message = "--".$boundary."\r\n"; $message .= "Content-Type: text/html; charset=UTF-8\r\n"; $message .= "Content-Transfer-Encoding: base64\r\n\r\n"; $message .= chunk_split(base64_encode($html_content))."\r\n"; $message .= "--" . $boundary . "\r\n"; $message .= "Content-Type: text/plain; charset=UTF-8\r\n"; $message .= "Content-Transfer-Encoding: base64\r\n\r\n"; $message .= chunk_split(base64_encode($plaintext))."\r\n"; $message .= "--".$boundary."\r\n"; $message .= "Content-Type: application/octet-stream; name=\"$outputPDFname\"\r\n"; $message .= "Content-Transfer-Encoding: base64\r\n"; $message .= "Content-Disposition: attachment; filename=\"$outputPDFname\"\r\n\r\n"; $message .= $attachment."\r\n"; $message .= "--".$boundary."--"; // header information $headers = "From: $from\r\n"; $headers .= "Reply-To: contact@mydomain.fr\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n"; // send email if (mail($to, $subject, $message, $headers)) { echo "Email with attachment sent successfully."; } else { echo "Failed to send email with attachment."; } The email went through once with the attachment Then I had this weird email : This is a sample email with attachement--655feab3a6c7f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: base64 VGhpcyBpcyBhIHNhbXBsZSBlbWFpbCB3aXRoIGF0dGFjaGVtZW50LS02NTVmZWFiM2E2YzdmDQpD b250ZW50LVR5cGU6IHRleHQvcGxhaW47IGNoYXJzZXQ9VVRGLTgNCkNvbnRlbnQtVHJhbnNmZXIt RW5jb2Rpbmc6IGJhc2U2NA0KDQo= --655feab3a6c7f Content-Type: application/octet-stream; name="bon-cadeau-couple-1700784819.pdf" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="bon-cadeau-couple-1700784819.pdf" Then nothing The logs aren't showing any error Here's what I have : Nov 24 00:31:13 ip-172-26-0-118 postfix/pickup[1435549]: A2A3780437: uid=1 from=<daemon> Nov 24 00:31:13 ip-172-26-0-118 postfix/cleanup[1435594]: A2A3780437: message-id=<20231124003113.A2A3780437@mydomain.fr> Nov 24 00:31:13 ip-172-26-0-118 postfix/qmgr[1208021]: A2A3780437: from=<daemon@mydomain.fr>, size=681, nrcpt=1 (queue active) Nov 24 00:31:14 ip-172-26-0-118 postfix/smtp[1435596]: A2A3780437: to=<personnal-mail@hotmail.fr>, relay=ssl0.ovh.net[193.70.18.144]:587, delay=0.81, delays=0.02/0/0.57/0.23, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 52EEE1FE06) Nov 24 00:31:14 ip-172-26-0-118 postfix/qmgr[1208021]: A2A3780437: removed I can't seem to figure out why the heck this doesn't work The only thing I'm 99% sure is that the mail isn't received because of the code I'm trying to pass in mail() I'm 100% sure that my mail is sent. I'm 99,99% sure that it's delivered (at mx.outlook.com) since I don't receive back any "undelivered" message Do any of you know how mails work deep from the inside ? Somebody knows more headers I should fill to ensure high delivering ? Has anyone an idea on what can possibly be wrong in my code ? Let's get over the basic questions : Yes, all my variables are right and work Yes emails can be sent from my server (tested from postfix using command line) Thanks a lot to you all
-
Curious. When querying SQL data in PHP, if I want to output data from a table result with a fetch_assoc, I'd have to always use column names. If I know the column position, is there not an option to just get the row for the position of the column rather than the name of it? If an SQL table exists like this: ID, DOB, first_name, last_name and I want Date of birth and I know it'll always be the 2nd column, a pseudocode like it would be something like: $row[1]; instead of how you'd always have to reference it: $row["DOB"]; Sort of getting annoyed with how rigid PHP is when it comes to SQL. If I could just use positions I could make my code far more flexible instead of hardcoding each column on its own. On second thought, I feel like this is a non issue and I'm just looking at a roundabout way of overcomplicating my code. Am I going insane?
-
So I am making a small school project, where I need to make a website which is a website with a Create, Read, Update and Delete functions, but I also need a search function. I made the website for the most part, but I am having a hard time making a search function on my website. Is there anyway I can make a search function onto my website? My code and picture of my website is here: https://imgur.com/a/4bGip7V
-
My friend made tables etc. to a website we're making in MySql. We made tables such as product, person, address and some other stuff. How do we implement it into a form? So we can have it displayed on the website?
-
So I am new at coding, and we needed to make a simple website with some simple functions. Everything seems to work and stuff, but I can't really find the reason why there is text where it says "Undefined Array Key" Isn't there a way to remove this? Everything in my database and in the code should have the same name.
-
Hello everyone, I am trying to create my first php site (locally) that should have two buttons that each execute a python script when clicked. Since I ahven't really worked with php yet I don't really know where to start here. I already have the php script active that prints out the current time and is available over the local ip so I already know how to do that Any help is appreciated Thanks in advance
-
So, I am trying to do a "dynamic" loading part of my website (hosting business related) where it displays total clients, total tickets resolved etc. The data is to be fetched from SQL where it displays the highest number. Each SQL table has a ID to it (separate from client ID) and it is that field I want to load. The field is called "id" and I want the code to load the highest number. So if there are an ID number "10", that number will be displayed, and if a new client registers, the new ID will become "11" and then that number should be displayed. How can I make this work as efficient as possible?
-
Hello everyone, I have been struggling to find out what exactly is causing this issue. I am setting up a wordpress.org website at home and it seems I'm running to a PHP problem so I'm curious if anyone has any insight at to what might be happening. I did already post a support topic over on WordPress but its not travel very much. Some things in this post are WordPress specific but I think this may be a PHP issue ultimately. I can not get past the step on connecting to the SQL database for setting it up for the first time. In the Debug log I get the following: PHP Fatal error: Uncaught Error: Call to undefined method wpdb::mysqli_connect() in E:\Website\wwwroot\wp-includes\wp-db.php:632 What is my Setup: Windows Server 2012 R2 IIS 8 Webserver PHP 8.0.11 Mysqlnd 8.0.11 WordPress 5.8.1 My SQL 8.0.26 What I have confirmed: •The Mysqli extension is enabled and ran a script on the site to show what's being loaded (php print_r(get_loaded_extensions());) •The Mysqli can connect to my database by using $conn = new mysqli(information goes here); •I do have full admin rights to the database on localhost •IIS Webserver has correct Modify permissions for the website directories and a Temp Directory •Other PHP code is executing as intended such as the examples above to confirm the webserver is able to do so. •wp-config.php has the correct login information •WP_USE_EXT_MYSQL argument does not exist in wp-config.php file What have I tired so far: •Restarting everything •Trying another fresh install •Switching to PHP 7.4 (stops at the same error) •Experimented with different code replacing line 632 in wp-dp.php with example code above $conn = If I could perhaps get some help with what exactly is going wrong or if it seems like I have not tried something. Thank you =)
-
so i dont know whats really going on here, but its confusing the hell out of me. so i set an NGINX+PHP-FPM server, with all my needed extinctions. I get this url from facebook: https://***/posts/?post=**UUIDv4***&fbclid=**** nothing weird about the URL but when i open the URL, my PHP session changes, along with a logout of my user. when i refresh the screen after that URL is used, it does logout again. nginx conf: server { root /***/; index index.php; server_name ***; location / { # try_files $uri $uri/ =404; try_files $uri $uri/ /index.php$uri$is_args$args; } location /posts/ { # try_files $uri $uri/ @rewrites; } # pass PHP scripts to FastCGI server # location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; } location @rewrites { rewrite ^/posts/(?<id>[a-zA-Z0-9]+)$ /posts/?post=$id; } #below here is SSL stuff for Certbot } the server is Behind a proxy: (the proxy config) server { server_name ***; location / { proxy_pass "https://192.168.0.155:443"; proxy_set_header HTTP_Country-Code US; proxy_pass_request_headers on; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_cache_bypass $http_upgrade; proxy_set_header Connection 'upgrade'; } #below here is SSL stuff for Certbot } PHP session settings: main issue: When using other than ?post= queries, the session expires, and i dont know why. i can provide any more details, just let me know
-
I have these three tables in PHPMyAdmin MySQL. I am trying to make a website where I can add a product to a cart. Products - [Id, Name, Description, Price] Carts/Lists [Id, TotalPrice] ProductsInCarts [CartId, ProductId, Quantity, Price, TotalPrice] But I have no idea how to relate them or how many characters they should allow, neither do I know what type or attribute should be added. I was thinking that products are added to basket in ProductsInCarts where CartId relates to Id in Cart Table, ProductId to Id in Products etc. But I am not sure how to do it.
- 6 replies
-
- mysql
- phpmyadmin
- (and 4 more)
-
My code: session_start(); $time = time() + 5; if (isset($_SESSION['udi_v1']) && $time >= $_SESSION['udi_expire']) { # skip echo "NO SKIP"; } else { function guidv4($data = null) { $data = $data ?? random_bytes(16); assert(strlen($data) == 16); $data[6] = chr(ord($data[6]) & 0x0f | 0x40); $data[8] = chr(ord($data[8]) & 0x3f | 0x80); return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); } $_SESSION['udi_v1'] = guidv4(); $_SESSION['udi_expire'] = time(); echo "NO SKIP________"; } var_dump($_SESSION); my goal: i want to make a new guidv4 every 15 minutes. So if the udi_expire time is above 900 seconds, then refresh it if the time is not the 900 seconds, then dont do anything where did i go wrong?
-
My end goal: On like youtube, they show a little thing in the bottom that says "5 mins reaming". I have no idea where to start, but i am Using FFMPEG: $format = new Streaming\Format\X264(); $format->on('progress', function ($video, $format, $percentage){ global $time; global $time_init; $url_23 = '/home/nrrinc/Desktop/HLS2/2/'.$time.'/'; // You can update a field in your database or can log it to a file // You can also create a socket connection and show a progress bar to users //echo sprintf("\rTranscoding...(%s%%) [%s%s]", $percentage, str_repeat('#', $percentage), str_repeat('-', (100 - $percentage))).''; $myfile = fopen($url_23."txt.status", "w") or die("Unable to open file!"); //$txt = sprintf("\rTranscoding...(%s%%) [%s%s]", $percentage, str_repeat('#', $percentage), str_repeat('-', (100 - $percentage))).''; $txt = sprintf("%s%", $percentage, str_repeat('#', $percentage),).''.'<br>'; fwrite($myfile, $txt); fclose($myfile); ### I want to echo how much time is remaining til the render is done });
-
I am trying to make a custom contact us form for a website I made using google sites (I would prefer not to use google forms). I found some really good html and css codes however they need a php file named "contact-form-process.php" to work since the hosting for google sites isnt exactly adjustable the only way to get code to run on the website is the "insert embed" feature that allows you to add html code. I was wondering if there was a way to get all three hmtl css and php into one. You can probably tell I'm not exactly an expert. thanks for the help
-
Hi! I want to create or look into creating a website for Files sharing, with user accounts that can logg in and see their specific files and nothing else. I have some experience with HTML/CSS as i have made a few basic websites before, nothing spectacular think early 2000's Basically i wanna see what it takes and if i'm able to do it I put SQL and php in the tilte as i assume that's what i need to make something like that. If someone could please point me in the right direction i would appreciate it!
-
I want to create a little shopping website for a school project. I need to have some products, where I can add them to the shopping cart. I know how to make the products, but I don't know how to make a button where I can add the product to the shopping cart. I also want a shopping cart where I can see the items, delete them. I also need some kind of create profile area, where I can create data, search for data, delete data, and update data. If I want to add my name to a list, then I would need to add it to a list and update the name, delete the name, and search for lastname for example and find the data. I tried finding guides, but everything I found was too complex and had too many things. I don't know if there is any guides to this, but if anyone knows, then I would really appreciate a link or something.
-
-
Hi, i start by saying that i have never used php and i do not even know from where to start, i found a piece of code that in a Hmailserver topic that should be able to create user from a webpage to my server. i do not need to use this for a "public" website only for friends and for learning something new. where do i have to put this code? Thank you.
-
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\techponya\index.php on line x <?php $sql2 = "SELECT * FROM artikel WHERE kategori='technews' DESC() LIMIT 5"; $hasil2 = mysql_query($sql2,$dbconn); while ($techponya = mysql_fetch_array($hasil2)){ ?>
-
When hosting php pages it simply gives me the source text. So far I've installed apache2, php and mysql. Followed this tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-22-04 Oops. Someone pls move this to programming Any ideas on what I could try next?
-
So I have a system that allow multiple discount to be applied on a checkout. The products can have more than one categories tag. Each discounts have its own categories tags list that it is not allowed to be applied to. The discount only have fixed amount. No percentage. The deal is as long as there is a product in the checkout that doesn't have the category that is listed in the discount, the discount can be used. Albeit the max amount will be limited to the applicable products. Any extra will be forfeited. Example: Discount A ($50) Excluded Category: [Accessory, Summer] On Checkout: Product A [Accessory, Winter] - $50 Product B [Shoe, Winter] - $30 In this case Discount A can be applied since it is applicable to Product B Checkout with applied discount: Product A [Accessory, Winter] - $30 Product B [Shoe, Winter] - $30 Discount A - ($30) - only $30 cause the only applicable amount is product B. $20 is forfeited. Now here come the complex part. I need to apply algorithm where the maximum amount of discount could be achieve Example: Discount A ($30) Excluded Categories: none Discount B ($40) Excluded Categories: [Shoe, Summer] On Checkout: Product A [Accessory, Winter] - $50 Product B [Shoe, Winter] - $50 If it were Simple Algorithm of first come first serve, the result will be On Checkout with discount: Product A [Accessory, Winter] - $50 Product B [Shoe, Winter] - $50 Discount A - ($30) - applied discount for product A since product A came 1st Discount B - ($20) - applied discount for the remaining value of product A. limited to $20 cause cannot apply discount to product B. the other $20 is forfeited I need to make algorithm where it is smart enough to make use the full discount amount like this: Product A [Accessory, Winter] - $50 Product B [Shoe, Winter] - $50 Discount A - ($30) - applied discount anywhere since the discount doesn't have any limitation(can be from single product or can be from summation of multiple products) Discount B - ($40) - applied discount for product A. Thank you in advance
-
I am designing a critical tracking app in Android studios ("Ik flutter is a better choice") but I went with android studio as I wanted to Improve my java ... as well as a Struggle that popped me in the job was 1)server designing I want a server suggestion where around 2k users and over 40 providers (providers write data and users read data from db) I want the spects to design a server 2)How do u even make a server end without a PHP based volly Engine which makes me mad seeing the PHP stuff I want the server end with java any Idea ... It would be a great help to support the 2ed point **Note 2ed one is mandatory
-
package main import ( "database/sql" "fmt" "log" _"github.com/go-sql-driver/mysql" ) func main() { db, err := sql.Open("mysql", "SQL CONNECTION") defer db.Close() if err != nil { log.Fatal(err) } result, err := db.Query("SELECT post_id,author FROM posts;") if err != nil { panic(err) } for result.Next() { var post_id string var author string var count int err = result.Scan(&post_id, &author) if like := db.QueryRow("SELECT COUNT(post_id) as count FROM rating_info WHERE post_id = '?' AND rating_action = 'like'",post_id).Scan(&count); if err != nil { fmt.Println(fmt.Sprintf("%#v", err)) panic(err) } fmt.Printf("Id: %d Name: %s\n", post_id, author) fmt.Println(like.Scan(count)) fmt.Println(like) } // database object has a method Close, // which is used to free the resource. // Free the resource when the function // is returned. defer db.Close() } end goal: I want to use like.count, how can i do this in GOLANG (coming from PHP?)
-
<?php $server = "localhost"; $user ="root"; $password=""; $db="pdophp"; $dbcon = new PDO("mysql:host=$server; dbname=$db", $user, $password ); try{ $dbcon->exec("insert into studentstable(name,age,class,gender) values('vinodth',26,11,'male')"); echo 'inserted successful'; }catch(PDOException $e) { echo $sql . "<br>" . $e->getMessage(); } ?> Code is working. Values are inserting but Twice into the Table. I tried but where I am doing wrong. Could you help plz.
-
I am trying to get a php file to show the picture in a table and not just the file name listed in mysql. This is what i have now: if($row = $sth->fetch()) { ?> <br><br> <table> <tr> <th>Bilde</th> <th>Navn</th> <th>Rase</th> <th>Beskrivelse</th> </tr> <tr> <td><?php echo $row->bilde;?></td> ------------------------------------------------This is where I would like the picture to be shown. Now it just shows me the file name. <td><?php echo $row->navn;?></td> <td><?php echo $row->rase;?></td> <td><?php echo $row->beskrivelse;?></td> </tr> </table> <?php
-
I'm trying to create an overview of the Lord of The Rings movies where you can click on one of the movies and get an overview of witch characters are in that movie. I have managed to get an overview of the races in the movies where you can click on one of the races and see the characters in that race. This is the diagram layout in mysql: This is the PHP code that gives me an overview of the races once I press the link in the php document that gives me an overview of the races with links. <?php if (isset($_GET["rase_id"])) { $rase_id =$_GET["rase_id"]; $rase =$_GET["rase"]; } else { die("Du har ikke angitt en rase_id."); } include "kobling_midgard.php"; $sql = "SELECT * FROM midgard.karakterer where karakterer.rase_id=$rase_id"; $resultat = $kobling->query($sql); echo "<table>"; echo "<tr>"; echo "<th>Bilde</th>"; echo "<th>Navn</th>"; echo "<th>Beskrivelse</th>"; echo "</tr>"; while ($rad = $resultat->fetch_assoc()) { $bilde = $rad["bilde"]; $navn = $rad["navn"]; $beskrivelse = $rad["beskrivelse"]; echo "<tr>"; echo "<td><img src='bilder/$bilde' alt='karakterer'></td>"; echo "<td>$navn</td>"; echo "<td>$beskrivelse</td>"; echo "</tr>"; } echo "</table>"; ?> This is the code I have for making the connection between the "film", "deltakelse" and "karakterer" tables. <?php if (isset($_GET["film_id"])) { $film_id =$_GET["film_id"]; } else { die("Du har ikke angitt en karakter."); } include "kobling_midgard.php"; $sql = "SELECT * FROM midgard.deltakelse where deltakelse.film_id=$film_id "; $resultat = $kobling->query($sql); echo "<table>"; echo "<tr>"; echo "<th>Navn</th>"; echo "<th>Beskrivelse</th>"; echo "</tr>"; while ($rad = $resultat->fetch_assoc()) { $navn = $rad["navn"]; $beskrivelse = $rad["beskrivelse"]; echo "<tr>"; echo "<td>$navn</td>"; echo "<td>$beskrivelse</td>"; echo "</tr>"; } echo "</table>"; ?>