PHP - Basic Mail() Question
I'm guessing this is more of a hosting/mail question than specifically php, but here goes...
I have this very basic code to send a test email: <?php $to = 'me@mydomain.com'; $subject = 'Test email'; $message = "Hello World!"; $mail_sent = mail( $to, $subject, $message); echo $mail_sent ? "Mail sent" : "Mail failed"; ?> and the following in my php5.ini: Quote [mail function] SMTP = relay-hosting.secureserver.net sendmail_from = admin@malvernaquarium.com When the mail is received, it's showing as coming from "auserid@p3nlh263.shr.prod.phx3.secureserver.net". How can I get this to show as something more reasonable and related to my domain? Ideally something more like admin@malvernaquarium.com. Thanks in advance! Greg Similar TutorialsI have a notification system that notifies users of new comments, inside the email I have images, some of the logo, some of different people, everything shows up fine on my computer (yahoo email), however in the iPhones email application no images show up, there are just the blue squares with the question marks in them. I'm not sure what I'm missing. Code: [Select] $from = "Kithell <notifications@kithell.com>"; $headers = "From:" . $from ."\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $subject = name($from_id, 'fl').$action; $message = '<html><body> <style>@charset "utf-8"; /* CSS Document */ .e-container { background-color: #FFF;position: relative;width: 90%;min-height:1px;margin-right: auto;margin-left: auto; } .e-container .e-m-header { padding: 2px; background-image: url(http://www.kithell.com/assets/tall-grey-header.png); background-repeat: repeat-x; border: 1px solid #CCC; background-position: bottom; display: block; text-align: center; } .e-container p { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; color: #666; vertical-align: text-top; display: inline-block; } .e-container .e-usr-photo { display: inline-block; margin: 10px; float: left; background-color: #F4F4F4; } .e-container p a { font-weight: bold; color: #3F60A3; text-decoration: underline; padding: 0px; float: left; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 0px; } .e-container .e-quotes { font-size: 20px; font-weight: bold; color: #999; font-family: Tahoma, Geneva, sans-serif; display: block; padding: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 75px; margin-top:10px; } .e-container .e-message { font-size: 13px; color: #333; padding: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 10px; clear: none; display: inline; }</style> <div class="e-container"><div class="e-m-header"><img src="http://www.kithell.com/assets/kithell-logo.png" /></div><img class="e-usr-photo" src="http://www.kithell.com/'.photo($from_id, 55).'" /><br /><p><a target="_blank" href="http://www.kithell.com/#/profile&id='.$from_id.'">'.name($from_id, "fl").' </a> '.$action.'<div class="e-quotes">"<p class="e-message">'.nl2br(htmlentities(stripslashes($message))).'</p>"</div></p></div></body></html>'; mail($to,$subject,$message,$headers); Hello, Im from the Netherlands and i have a little question about php. I have a form in php where administrators can make new users. They can fill in a name, password, age and can select a role. The role is a dropdown menu where they can select athlete, researcher and trainer. My problem is that when they select a role, i want that selected role transfert to a php variable. I want to use the variable in a if statment, when sporter selected a new dropdown appears with options like tennis, hockey.... I have seen a lot on google about this with jquery and stuff, but i cant find a good example. Can u help me? Thanks. Does it matter where you start your session at? Does it have to be before the <!doctype> tag or can it go anywhere in the page? Hi, can you help me please? I have some code written about 5 yrs ago that is for example like this echo"<div class=\"select\">"; echo"<br /><br />\n"; echo"</div>\n"; echo"</div>\n"; echo "<p><b>$address</b></p>\n"; Does it make any difference at all if I amended it to echo"<div class=\"select\"><br /><br /></div></div><p><b>$address</b></p>"; ie coding errors or increase load time? also when should I use \n"; or "; Please forgive my ignorance but I am a self taught php writer and have managed to teach myself but just need a little help. Cheers Quote from: http://www.killerphp.com/tutorials/object-oriented-php/php-objects-page-1.php getter and setter names should match the property names. This way, when other PHP programmers want to use your objects, they will know that if you have a method/function called 'set_name()', there will be a property/variable called 'name'. Is this an accurate statement? Even if there's like 20+ properties? That would be 40+ methods and that's not including doing anything with those properties but setting/getting. That sounds...I don't know...against the grain. I would like to keep all my classes in a folder placed within the htdocs folder where my php script runs. Let's say the classes folder is com\jimslounge\classes. From my script can I instantiate a class like this $myClass = new com\jimslounge\classes\Jimsclass(); Does it work something like that? I would hate to have to use include to access classes. is it okay to name a column "date" in a table ??? just want to know whether this could mess up everything thanks in advance <?php if (!isset($_GET['register'])) { echo "register stuff here"; } elseif (!isset($_GET['login'])) { echo "login stuff here"; } elseif (!isset($_GET['forgotpassword'])) { echo "password recovery stuff here"; } else { echo "default page stuff here"; } ?> you get what i'm going for, but it kinda messes up this way with different contents on different places? help I have inherited some pages from someone else who wrote them and as I am a newbie and the code is quite old I suspect it needs to be updated in order to work. I have two variables $p and $service that were passed from page 1 to page 2 via the URL. On page 2 I have updated the code for echo $_GET['$p'] etc and I am happy with that. Lower down on page 2 within an HTML form the author has Code: [Select] <input type="hidden" name="service" value="<? echo $service; ?>" /> <input type="hidden" name="p" value="<? echo $p; ?>" /> with the intention of putting these variables in the URL for page 3 I have to assume. Page 3 begins with this code Code: [Select] "completeyourorder.php?p=" . $p . "&service=" . $service; but the variable values are not showing up in the URL and I can not seem to use them on page 3. In other words they don't seem to be available to me. I'd appreciate help to change the page 3 code above or the page 2 code so that it works as intended. I found some posts and researched tutorials but all that I have tried has not worked. Thanks Glenn Hello!
I'm newbie in PHP(started 3 days ago), and i have two questions about the same topic, i hope you can answer me.
1- Is there methods in php for interaction with webpages as javascript, as they simulate a user interacting with these pages? For example, the method click () or the getElementsByClassName () for you to find something specific on the page. There are methods that do this in php?
2- To interact with a website using a sript (to click on links or save the url of pictures in an array) i start "JavaScript Scratchpad" Firefox with Shift + f4 and then it runs the script there, is just be on the page i want. If i want to do something similar in php, how can i run this script on my browser or is it done another way?
Thanks!
probably a very stupid question, but i pose it because it's counterintuitive for me to write it: i find in alot of wordpress code if statements like: if ( false === $var) i suppose it's the same as if ( $var === false) ? why would one right it in the first way? OK, I think this is easy, but I just can't seam to get it figured out. I have this piece of code echo '<img src="maps/' . $map . '.jpg" />'; And what I want to do is if that $map is not in the directory I want it to display a standard image that I know is in the directory. So basically I want the alt tag to be a image instead of text. I just want to ask the logic of making a chatroom. Is it correct if i prepare a table in MYSQL, php script to submit whatever words typed and use AJAX to refresh every second to be sure that all input displayed thanks Hi, I just started learning PHP... Below is my first programme infact.. Out put is not coming when i type some thing in input boxes... Can somebody suggest where is the error... Index.php <html> <head> <title>Welcome to our site</title> </head> <body> <form method="POST" action="submit.php"> <label for ="business_name">Business name</label> <input type="text" id="business_name" \><br/> <label for ="contact_person">Contact person</label> <input type="text" id="contact_person" \><br/> <label for ="Telephone">Telephone</label> <input type="text" id="Telephone" \><br/> <label for ="FAX">FAX</label> <input type="text" id="FAX" \><br/> <label for ="Mobile">Mobile</label> <input type="text" id="Mobile" \><br/> <label for ="Addres_line_1">Addres_line_1</label> <input type="text" id="Addres_line_1" \><br/> <label for ="Addres_line_2">Addres_line_2</label> <input type="text" id="Addres_line_2" \><br/> <label for ="Addres_line_3">Addres_line_3</label> <input type="text" id="Addres_line_3" \><br/> <label for ="Addres_line_4">Addres_line_4</label> <input type="text" id="Addres_line_4" \><br/> <label for ="City">City</label> <input type="text" id="City" \><br/> <label for ="Pin_code">Pin_code</label> <input type="text" id="Pin_code" \><br/> <label for ="State">State</label> <input type="text" id="State" \><br/> <label for ="email">email</label> <input type="text" id="email" \><br/> <input type="submit" value="Please submit the details" name="submit"/> </form> </body> </html> submit.php <head><title>Your submission details</title></head> <body> <H3>YOU HAVE SUBMITTED THE FOLLOWING DETAILS</H3> <?php $business_name= $_POST["business_name"]; $contact_person = $_POST["contact_person"]; $Telephone = $_POST["Telephone"]; $fax = $_POST["FAX"]; $mobile = $_POST["Mobile"]; $address1 = $_POST["Addres_line_1"]; $address2 = $_POST["Addres_line_2"]; $address3 = $_POST["Addres_line_3"]; $address4 = $_POST["Addres_line_4"]; $city = $_POST["City"]; $pincode = $_POST["Pin_code"]; $state = $_POST["State"]; $email = $_POST["email"]; echo "Your business name".$business_name.'<br/>'; echo "Contact person".$contact_person.'<br/>'; echo "Telephone no.".$Telephone.'<br/>'; echo "Fax No.".$fax.'<br/>'; echo "Mobile No.".$mobile.'<br/>'; echo "Address line one".$address1.'<br/>'; echo "Address line two".$address2.'<br/>'; echo "Address line three".$address3.'<br/>'; echo "Address line four".$address4.'<br/>'; echo "Your City".$city.'<br/>'; echo "Your Pincode".$pincode.'<br/>'; echo "Your State".$state.'<br/>'; echo "Your email".$email.'<br/>'; ?> <a href=index.php>Home</a> </body> </html> I have several fields in a database in which some could be blank. I'd like to echo out 'Not Assigned' if that's the case. Based on my limited experience with PHP this is the way I'm going about it: Code: [Select] if ($tech == "") { $tech = "Not Assigned"; } if ($crew == "") { $crew = "Not Assigned"; } if ($number == "") { $number = "Not Assigned"; } I'm pretty certain there is a way to simply place all of the variables into an array to determine if they are empty or not - Followed by changing the variable to 'Not Assigned' one time rather then repeating code over and over again. The way I'm doing it will work, however, something tells me there is a much more efficient way. sorry guys its been a long day and this is an extreme newbie question but for whatever reason right now I cant wrap my head around the concept right now... say for instance one wanted to make a db for job postings, where one could go and see many different categories etc etc. Would you create a table "jobs" and then create rows for the types ie) Accounting, Business, Customer Service, etc. - or would those be all seperate tables as well? Cause im just thinking of the INSERT INTO query, and say I wanted to add a job but I only wanted to add one to the Customer service portion of the jobs table...thats why im curious if everything should be different tables so you could just do INSERT INTO customer_service etc etc and then have all of the persons names/creditials there? OR is it possible to create a table within a table? or am I simply going nuts here? lol. thanks I got a script that receive info from paypal "ipn" when someone is making a payment from my shop. I wanted to edit the script a bit as i am adding a bonus system to it. After i added Quote // Bonus system vars if ($item_name == '301') { $point == "1"; } elseif ($item_name == '302') { $point == "2"; } elseif ($item_name == '303') { $point == "3"; } elseif { $point == "0"; } And Quote $bonus1 = "update Bonus set points=points+'$points' where username='$username'"; mysql_query("$bonus1"); $bonus2 = "update Bonus set points_total=points_total+'$points' where username='$username'"; mysql_query("$bonus2"); $bonus3 = "update Bonus set $item_name=$item_name+1 where username='$username'"; mysql_query("$bonus3"); The script wont work. But it does when i remove those things. I think my problem is at the if,elseif i just dont know why. Do i need to put it in some kind of while loop? Here is the full php code Code: [Select] mysql_connect('xxxxx', 'xxxx', 'xxxxxx'); $notify_email = "xxxx@xxxx"; // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } // post back to PayPal system to validate $header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30); // assign posted variables to local variables $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; $buyer_firstname = $_POST['first_name']; $buyer_lastname = $_POST['last_name']; $timestamp = $_POST['payment_date']; $address_street = $_POST['address_street']; $address_city = $_POST['address_city']; $address_state = $_POST['address_state']; $address_zip = $_POST['address_zip']; $username = $_POST['custom']; // Bonus system vars if ($item_name == '301') { $point == "1"; } elseif ($item_name == '302') { $point == "2"; } elseif ($item_name == '303') { $point == "3"; } elseif { $point == "0"; } mysql_select_db('redlite'); if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { if ($payment_status == 'Completed') { $sql = "insert into tblMail values ('','$txn_id','$payer_email',' $item_name','$timestamp','','','','$payment_amount $payment_currency','$buyer_firstname $buyer_lastname','$address_street $address_city , $address_state $address_zip','','','$username')"; mysql_query("$sql"); $bonus1 = "update Bonus set points=points+'$points' where username='$username'"; mysql_query("$bonus1"); $bonus2 = "update Bonus set points_total=points_total+'$points' where username='$username'"; mysql_query("$bonus2"); $bonus3 = "update Bonus set $item_name=$item_name+1 where username='$username'"; mysql_query("$bonus3"); $ttlpay_sql = "update totalpay set total=total+'$payment_amount' where id='1'"; mysql_query("$ttlpay_sql"); mail($notify_email, "CLVerified", "$res\n $req"); } else { mail($notify_email, "CLVerified - But not completed". "$res\n $req"); } } else if (strcmp ($res, "INVALID") == 0) { mail($notify_email, "CLINVALID IPN", "$res\n $req"); } } fclose ($fp); } ?> Hey y'all, I'm trying to write a PHP script for a login function. There are three elements, two text fields (username and password) and a button which calls the script. Segment from index.php file: <form action = "login.php" method = "POST"> Admin Login: <br> Username: <input type = "text" name = "usernameField"/><br> <!-- Password field--> Password: <input type = "password" name = "passwordField"/><br> <!-- Username field --> <input type = "button" value = "Login" name = "submitButton"/> <!-- Login button --> </form> Segment from login.php file: <?php $connect = mysql_connect("localhost", "root", "root"); if(!$connect){//If user can't connect to database die('Could not connect: ' . mysql_error()); //Throw an error } mysql_select_db("colin_db", $connect); //Get given username and password from username field and password field $givenUsername = $_POST["usernameField"]; $givenPassword = $_POST["passwordField"]; $myQuery = "SELECT * FROM ADMINS WHERE USERNAME = '$givenUsername' AND PASSWORD = '$givenPassword'"; $queryResult = mysql_query($myQuery); $numRows = mysql_num_rows($queryResult); if($numRows == 1){ //If the details are correct... //Reload the page and login echo "<script type = 'text/javascript'> window.location.reload() </script>"; } elseif($numRows == 0){ //Else if the details are not found //Display error accordingly echo "Details not correct!"; } mysql_close($connect); ?> The problem is, when I click the login button, it doesn't do anything. What am I missing? (The information in the database is correct) Thanks, Jake Hi, Im learning php, but Im a bit confused on this basic problem. I have the following code: <?php include "tax.php"; $price = 95; echo "Price before tax: $price <br>"; echo "Price after tax: "; echo add_tax ($price); ?> Which uses the function below <?php function add_tax ($amount) { $total = $amount * 1.09; return $total; } ?> When I execute the code I can see that it does work, but I do not understand why this part works! echo add_tax ($price); There is no multiplier symbol here, so is the function performed on the ($price) variable simply because of where it is located on this line of code? Thanks Hello there, I'm very new to PHP and I need some help (please!) Basically I'm writing an actionscript application and I am using a php file to save an image to the server, the problem is I define a name in actionscript before I send the information to the php and it continuously saves over the same file.. Ideally I would like to attach the (jpg) image to an email, send the mail and delete the image ready for a new image to be created.. is this possible ? At least, I would like to add a +1 to each filename to stop the file being saved over continuously ! Thanks in advance for any help <?php $fileName = $_GET['filename']; $fp = fopen( $fileName, 'wb' ); fwrite( $fp, $GLOBALS['HTTP_RAW_POST_DATA'] ); fclose( $fp ); ?> |