PHP - Php Newbie Here - Please Help Me With A Specific Problem
I've been searching for a couple of days on google using keywords, trying to figure out why this form sends blank emails. I've found several different ways to write something like this, including what's below, but for the life of me I haven't figured it out.
Can anyone help a brother out? <?php $email = $_REQUEST['email']; $message = $_REQUEST['date']; $message .= $_REQUEST['location']; $message .= $_REQUEST['quantitymodel']; mail( "name@email.com", "Email Contact Form", $message, "From: $email" ); header( "Location: thankyou.html" ); ?> Similar TutorialsHi PHPFreaks.com I wrote in here a while ago about updating table rows by selecting rows which end dates is greater than the current day, much like a experation dates with blog posts in a CMS. I was told to make sure my datatype for the end dates in the database was the datetime format is YYYY-MM-DD HH:mm:SS now I have now changed that, but I am still have trouble creating a query that does exactly what I mentioned. mysql_query("UPDATE ". $db_prefix ."events WHERE end_time >= TIMESTAMP: Auto NOW() SET cat = 1" ); Now what I am trying to is that if the current time is greater than the end date I need the "cat" row changed to 1 So thanks in advance if you can help me guys I use the Wholesale Suite Premium Prices plugin with WooCommerce. I have 6 specific wholesale roles out of 15 that I wish to hide two specific shipping methods from being selected for the 6 exceptions. I'm just trying this on my staging server at this time using a code snippet example that I found and modified for my specific conditions. Would the following work for this purpose? /* Hide specific shipping methods for specific wholesale roles */ add_filter( 'woocommerce_package_rates', function( $shipping_rates ) { // User role and shipping method ID to hide for the user role $role_shipping_method_arr = array( 'ws_silvia_silver' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_silver_pst_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_silver_tax_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_silver' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_silver_pst_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_silver_tax_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_gold' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_gold_pst_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_gold_tax_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_gold' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_gold_pst_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_gold_tax_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), ); // Getting the current user role $curr_user = wp_get_current_user(); $curr_user_data = get_userdata($current_user->ID); // Wholesale Suite Roles if (isset($current_user) && class_exists('WWP_Wholesale_Roles')) { $wwp_wholesale_roles = WWP_Wholesale_Roles::getInstance(); $wwp_wholesale_role = $wwp_wholesale_roles->getUserWholesaleRole(); // Loop through the user role and shipping method pair foreach( $role_shipping_method_arr as $role => $shipping_methods_to_hide ) { // Check if defined role exist in current user role or not if( in_array( $role, $current_user->roles) ) { // Loop through all the shipping rates foreach( $shipping_rates as $shipping_method_key => $shipping_method ) { $shipping_id = $shipping_method->get_id(); // Unset the shipping method if found if( in_array( $shipping_id, $shipping_methods_to_hide) ) { unset($shipping_rates[$shipping_method_key]); } } } } } return $shipping_rates; }); Any insights as to how to accomplish this would be greatly appreciated. Lyse Hi, Im pretty new to php but im have trouble understanding why my script is doing this. Forgive me for silly mistakes! Im creating a login/register website and once the person has logged in they get a message saying "Successful login, welcome username!" The php checks against a database of users in an if statement to check if the password is correct and then prints out the message. But at the end of the message the echo is printing out a 1. I get that because the echo is in an if statement its return true or 1 but I cant get it to not print out the 1. code snippet is - if ($username==$dbusername&&$password==$dbpassword) { echo "Successful login, welcome!"; } Hope that makes sense. Thanks for the help. Neil I got this code
<?php // Check if session is not registered, redirect back to main page. // Put this code in first line of web page. session_start(); if (!isset($_COOKIE["user"])) { header("location:login.php"); } include 'connection.php'; ?> <html> <head> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="HandheldFriendly" content="true"> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>EBS Service Skjema</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <?php include 'menu.php'; echo "<div class=\"bluebox\">"; if (isset($_GET['sted'])) { require_once('graph/jpgraph.php'); require_once('graph/jpgraph_line.php'); include 'connection.php'; // data $sql = mysqli_query($con, "SELECT * FROM diesel WHERE sted = '".$_GET['sted']."' GROUP BY WEEK(dato)"); $ydata = array(); $ydate = array(); while($row = mysqli_fetch_array($sql)) { $ydata[]=$row['krl']; $ydate[]=$row['dato']; } // Create the graph. These two calls are always required $graph = new Graph(600,250); $graph->SetScale('textlin'); $graph->title->Set('Pris Historikk'); $graph->xaxis->title->Set("Dato"); $graph->yaxis->title->Set("Pris"); $graph->xaxis->SetTickLabels($ydate); // Create the linear plot $lineplot=new LinePlot($ydata); $lineplot->SetColor('blue'); //$lineplot->SetFillColor('orange@0.5'); // Add the plot to the graph $graph->Add($lineplot); // Display the graph $graph->Stroke(); } else { echo "Du får ikke tilgang på denne måten."; } echo "</div>"; ?> </body> </html>but I get headers allready sent. I was earlier told to learn and code or make my apps different, but I'm totaly stuck cause I need to make a page with those stats. Not sure how I can make all my code be processed first then put into the html area. Is a function the way to go here ? Thanks for reading and hope someone can enlighten me HI there, i'm using a flash and php form. The problem lie in the PHP I only seem to get the field titles (Name and telephone) coming through and not the data they contain. Could somebody tell me what i'm doing wrong? <?php $sendTo = "myemail@gmail.com"; $subject = "An enquiry"; $headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " . $_POST["email"]; $message = "telephone: ".$strtelephone."\r\n"; $message .= "message: ".$strmessage."\r\n"; mail($sendTo, $subject, $message, $headers); ?> thank you I am learning PHP/MySQL and am modifying a tutorial to make a contact database. All I want is to be able to make a web page for each contact(record) and display one record on each webpage. I want to use the URL featu "http://www.mysite.com/script.php?=item1" type of thing Can any help me as I can't get it to work. I get no errors - it just doesnt display the info. I'm sure I cant be far off as I've only modified a working script ever so slightly. Code: [Select] mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); ?> <? $query="SELECT * FROM contacts WHERE id='$id'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; ?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Phone</font></th> <th><font face="Arial, Helvetica, sans-serif">Mobile</font></th> <th><font face="Arial, Helvetica, sans-serif">Fax</font></th> <th><font face="Arial, Helvetica, sans-serif">E-mail</font></th> <th><font face="Arial, Helvetica, sans-serif">Website</font></th> </tr> <? $i=0; while ($i < $num) { $first=mysql_result($result,$i,"first"); $last=mysql_result($result,$i,"last"); $phone=mysql_result($result,$i,"phone"); $mobile=mysql_result($result,$i,"mobile"); $fax=mysql_result($result,$i,"fax"); $email=mysql_result($result,$i,"email"); $web=mysql_result($result,$i,"web"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><? echo "$first $last"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$phone"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$mobile"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$fax"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><a href="mailto:<? echo "$email"; ?>">E-mail</a></font></td> <td><font face="Arial, Helvetica, sans-serif"><a href="<? echo "$web"; ?>">Website</a></font></td> </tr> <? ++$i; } echo "</table>"; ?> hello, I'm a beginner when it comes to PHP: I'm working on a log in system but i keep on getting the same errors which makes my system unreliable. this is the function I'm trying to use: if(pg_numrows($q) == 1){ echo "<p>Someone took that username</p>"; include "signup.php"; exit; } --> I'm using a postgresql database this is the warning I keep on getting: Code: [Select] Warning: pg_numrows(): supplied argument is not a valid PostgreSQL result resource in /var/ftpdirs/512544/PHP/login/adduser.php on line 13 I have the same problem when I try to look if an username is taken or not... when people try to register this is my adduser.php file: <?php session_start(); include "connectie_db.php"; $User_name = $_POST['user_name'] ; $User_pass = $_POST['user_pass'] ; $User_pass2 = $_POST['user_pass2'] ; $checkUsername= "SELECT user_name from tovanu.users where user_name = '$User_name';"; $q = $db->exec($checkUsername); if(MDB2::isError($q)){ echo "code: ".$q->getUserInfo(); exit(); } if(pg_numrows($q) == 1){ echo "<p>Someone took that username</p>"; include "signup.php"; exit; } If(strlen($User_name > 32)){ echo "<p>The username is too long</p>"; include "signup.php"; exit; } if($User_pass != $User_pass2){ echo "<p>Both passwords must be the same</p>"; include "signup.php"; exit; } $password = md5($User_pass); $add = "INSERT INTO tovanu.users (user_name,user_pass,user_email,user_date,user_level,naam,adres,plaats,postcode) VALUES ('$User_name','$password','email',current_date,1,'jef','jonhstraat','maaseik','3687')"; $execute = $db->exec($add) ; if(MDB2::isError($execute)){ echo "code: ".$q->getUserInfo(); exit(); } $_SESSION['user'] = $username; include "index.php"; ?> any help would be appreciated!!!!!!!!!!! Hello I've registered here last March and I'm just lurking around reading threads about php. Yesterday I've started to self studied php and today I've test some basic codes and I'm having difficulties on creating a table rows and columns. Here's my code. Code: [Select] <?php echo "<table width=\"100\" border=\"1\">"; $text = 'php'; $mac_var = 1; $mac_plus = 4; while ($mac_var < $mac_plus) { echo "<tr>"; { while ($mac_var < $mac_plus) { echo "<td>". $text . "</td>"; $mac_var++; } } echo "</tr>"; $mac_var++; } echo "</table>"; ?> what I want is, it should have 3 columns and 3 rows. But I'm getting only 3 columns and 1 row only. I wonder what is the problem? Sorry for my ignorance as I'm on the 1st basic phase of using php codes. TIA! Hello all! Well, here's my dilemma. I understand how PHP and server side code works, I understand the important basics about PHP in general, I just need more specific help. I'm currently working with a partner in building a website that allows users to basically enter in information in text fields, add a picture to their post, and choose from a drop down menu what other page on the website they want the post to go to. (For all of the things I'm discussing here, I've drawn out pictures of what I want in Illustrator if anyone needs specifications.) Once the user presses "Submit" or "Accept" or whatever, it will post their information on the page they selected, organized with the picture a certain size on the left, and the text aligned ragged right on the right side of the picture. Below that, each "post" will be assigned a number based on the last post made to that page. So if I was the first one to post it, it'd show "1" in the data. I can imagine this isn't a simple process, but because I understand how PHP works, and also how comment systems in server side coding works, I just need to know certain things in the code, like organizing the inputed data when posted and what not. Any help or advice would be greatly appreciated by both me and my partner. Thanks! How can i call a specific row when ever a like. example : Code: [Select] $record = mysql_query("select * from table_name"); ($getValue= mysql_fetch_row($record) //i'm not sure what should i use. should i use mysql_fetch_array, mysql_ fetch_ assoc, mysql_ fetch_ object, mysql_ field_ name and etc. print $getValue[$column_name][0]; 0 = value 1st row in the database/table_name 1 = value 2nd row in the database/table_name 2 = value 3rd row in the database/table_name ...... .... ...... ..... etc. is there a code i can do except from using sql_fetch_array then loop and put in into a multidimensional array? Hi guys
I'll try keep this simple
I have been given access to a betting xml feed which requires my IP to be whitelisted.
I have whitelisted my home IP and it works fine.
I have whitelisted an IP on server 1 (linux, cpanel), this works fine
I have whitelisted an IP on server 2 (linux, cpanel), this doesn't work and I get:
"simplexml_load_file failed to open stream: http request failed!"
The IP is definitely whitelisted but I think it is something to do with the server. What could be blocking this?
allow_url_fopen and allow_url_include are both on by the way
Many thanks
Sam
Hey guys I have trouble picking the specific id of an entry i want to delete so please take a look at the codes first Here's the function for making the form: Code: [Select] function am_query_display_quick($page,$order ='DATE DESC'){ global $email; $conn = db_connect_2(); $color1 = "tableRowOdd"; $color2 = "tableRowEven"; $RowCount = 0; $result = $conn->query("SELECT pro,pro_update,ana,ana_update,cell,cell_update,cellother,cellother_update,gen,gen_update,genother,genother_update,author,author_update,other,other_update,id FROM mailing_list WHERE email = '$email' ORDER BY $order LIMIT $start_row, $max_per_page;"); echo "<form method = \"post\" action=\".{$_SERVER['PHP_SELF']}.\">"; echo "<table class=\"sortable\" id=\"query_quick2\" width=\"100%\" >\r\n"; echo "\t<tr><th></th><th>Promoter Locus</th><th>Update?</th><th>Anatomical Area</th><th>Update?</th><th>Cell Type</th><th>Update?</th><th>Other Cell Type</th><th>Update?</th><th>Genetic Background</th><th>Update?</th><th>Other Gen. Back.</th><th>Update?</th><th>Author</th><th>Update?</th><th>Other</th><th>Update?</th><th></th>\r\n"; if($result->num_rows){ while ($row = $result->fetch_array()){ $RowCount ++; $row_color = ($RowCount % 2) ? $color1 : $color2; echo "\t<tr class=\"$row_color\" ><td><input type=\"submit\" name=\"edit_mail\" value = \"Edit\"/></td> <td>{$row['pro']}</td><td>{$row['pro_update']}</td><td>{$row['ana']}</td> <td>{$row['ana_update']}</td><td>{$row['cell']}</td><td>{$row['cell_update']}</td><td>{$row['cellother']}</td> <td>{$row['cellother_update']}</td><td>{$row['gen']}</td><td>{$row['gen_update']}</td><td>{$row['genother']}</td> <td>{$row['genother_update']}</td><td>{$row['author']}</td><td>{$row['author_update']}</td><td>{$row['other']}</td><td>{$row['other_update']}</td> <td><input type=\"submit\" name=\"delete_mail\" value =\"Delete\"/></td> <td><input type =\"hidden\" name = \"id\" value=\"{$row['id']}\"/></td> </tr>"; } } echo "</table>"; echo "</form>"; And this is where the delete command comes into place (excerpt): Code: [Select] } elseif(isset($_SESSION['user_id']) AND isset($_POST['delete_mail'])){ //user is deleting existing queries $conn=db_connect_2(); $id = mysqli_real_escape_string($conn, $_POST['id']); echo $id; $sql2 = "DELETE FROM mailing_list WHERE id='$id'"; $result = mysqli_query($conn, $sql2) or mysqli_error($conn); $msgs[] = "Query deleted successfully."; $body = "account.php"; } yes it can delete entries all right but it doesn't delete a specific entry when i click the "delete" button near it somehow, it ALWAYS deletes the last row of entry at the table as you can see, i echoed out $id as it's referring to the LAST entry as well So my question is, how to delete a particular entry when i click the corresponding "delete" button?? Thanks I have fopen() code that works fine.. Code: [Select] $filename = "trade.php"; $filehandle = fopen($filename, 'w') or die("can't open file"); fclose($filehandle); But I want it to create the file "trade.php" in a specific directory called "tradepages". I tried changing the one line to be... Code: [Select] $filename = ".../tradepages/trade.php"; But that just gives an error saying no such directory exists (even though it definitely does). There has to be a way to create files in whatever folder/directory you want, right? Anyone know how, or what I'm doing wrong? Hi guys, i was having an issue with dates and although it leans a bit more into MYSQL I was hoping i could get some help ive searched all over the net for this so I dont know if im not thinking on how to ask this correctly or can't find it, but ill be as detailed as possible and hope that helps.
Ok I have a table that shows when payment was received on past invoices dating back to say 1995; The company processes 'ALL' invoices every month on the 9th, so if anything comes in from the first to the ninth it will be processed that month on the ninth. If it comes in from the tenth to the thirtieth or thirty-first it will be processed the following month.
The table already has a "Received" date filed and now I want to create a column on the table called "Processed Date" (adding the column is no problem don't need help with that part) that shows me the date we processed the invoice.
I know i have to use the "Received" field (because it shows what day the invoice was put into the system) but im not sure how to format the "Processed Date" field, so say the "Received" field shows an invoice came in on '1995-05-11', I want the "Processed Date" field to display it was payed on '1995-06-09' (notice that is the following month).
I thought i would put in a visual of what I was trying to do below:
So if I pull the two columns in MYSQL from that table I would see something like this:
Received Processed Date
1996-02-03 1996-02-09
1996-03-03 1996-03-09
1996-04-11 1996-05-09
1996-05-20 1996-06-09
1996-07-13 1996-08-09
If i could get some guidance/help on this i would really appreciate it.
thanks in advance!!
JL
Was just wondering if it's okay to make simple donations to other users on the forum. Just out of generosity.
If true, if I want to make a donation to a specific user how would I go about doing it? Just pm them asking for their paypal?
Edited by Monkuar, 12 October 2014 - 12:08 PM. I'm trying to parse 2 things. 1. Specific TD tags from a table. 2. Specific URLs from an HTML page. Here's part of the data I'm trying to parse: Code: [Select] <tr> <td class="f"> <a href="http://main1.site.com/x.html">Page 1</a> </td> <td>1572</td> <td class="a">Type: F</td> <td><img src="http://site.com/image.gif" title="N" alt="N" /></td> <td class="f">F</td> </tr> <tr class="x"> <td class="m"> <a href="http://main2.site.com/x.html">Page 2</a> </td> <td>1771</td> <td class="a">Type: M</td> Here's the parser that I'm working with: Code: [Select] <?php $html = file_get_contents('http://www.website.com/page.html'); // use this to only match "td" tags #preg_match_all ( "/(<(td)>)([^<]*)(<\/\\2>)/", $html, $matches ); // use this to match any tags #preg_match_all("/(<([\w]+)[^>]*>)([^<]*)(<\/\\2>)/", $html, $matches); //use this to match URLs #preg_match_all ( "/http:\/\/[a-z0-9A-Z.]+(?(?=[\/])(.*))/", $html, $matches ); //use this to match URLs #preg_match_all ( "/<a href=\"([^\"]*)\">(.*)<\/a>/iU", $html, $matches ); preg_match_all ( "/<a href=\"([^\"]*)\">(.*)<\/a>/iU", $html, $matches ); for ( $i=0; $i< count($matches[0]); $i++) { echo "matched: " . $matches[0][$i] . "\n<br>"; echo "part 1: " . $matches[1][$i] . "\n<br>"; echo "part 2: " . $matches[2][$i] . "\n<br>"; echo "part 3: " . $matches[3][$i] . "\n<br>"; echo "part 4: " . $matches[4][$i] . "\n\n<br>"; } ?> What I'm trying to output is: Code: [Select] <a href="http://main1.site.com/x.html">Page 1</a> Hits: 1572 <a href="http://main2.site.com/x.html">Page 2</a> Hits: 1771 ...for the entire table What I've managed to get out of it so far are the "Hits" with the "td" snippet. What I can't figure out is how to extra the full: <a href="http://main.site.com/p#.html">Page #</a> So my question is how can I make it look for just "<a href="http://main#.......">Page #</a>"? Currently it looks for every URL, which is not what I need. Hi there im trying to destroy a specific session i have been looking through many different ways on google but have yet to find one the reason i want to do this is because my website part of the website that is being made has to have a login to view everything and this login ontop to view restricted content, so far my logout has destroyed both sessions and i cant find an answer, all the nessecory scripts are listed below Login: <?php if(isset($_POST['code'])) { $host="***********"; // Host name $username="*************"; // Mysql username $password="************"; // Mysql password $db_name="******"; // Database name // Connect to server and select databse. mysql_connect($host, $username, $password); mysql_select_db($db_name); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); // encrypt password $encrypted_mypassword=md5($mypassword); $sql="SELECT * FROM members WHERE username='$myusername' and password='$encrypted_mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:jncomenu.php"); } else { echo "Wrong Username or Password"; } } ?> Check session: <? session_start(); if(!session_is_registered(myusername)){ header("location:JNCOlogin.php"); } ?> Logout: <? session_start(myusername); session_destroy(myusername); header("location:index.php"); ?> The first session is the same script bar [php][session_register("username"); session_register("password"); /php] Any help will be greatly appriciated. Thank, Blink359 |