PHP - Need To Pass A List Of Captured Data To External Source Via Url String
I need to pass captured data, basically, a list of email addresses that are being read from a CSV file and (1st) saved to an local database, then sent over to an external source via URL string.
I have everything working except - script opens the file, read and validates all emails in the specified column, and saves to local db. ISSUE: after validating then INSERTING the data into local mySQL db, I need to then pass each piece of data to an external source via URL string. Example: www.domain.com?email={$new_email} I was initially think to just add the URL in a header function but, I'm not sure if the HEADER() function the right method to pass all of the data - during the loop - via the URL string. For example, if the CSV file contain 500 emails: Q: how can I continue that loop until the last email read, passing each up to the external source via the URL string? I'm not sure if using the HEADER() function at the end of the script - but within the loop - will interate and send each capture email via that URL string. Can anyone advise a possible solution to this? thanks Similar TutorialsHi, I'm trying to setup a quick PHP script that will grab the email from the url (see below) and after inserting into MySQL db - which is working fine - the script will complete two additional tasks: 1. send that same captured email out to a external db as in shown via http://domain1.com/insert.php?email=$lead (example), but then send to a DIFFERENT source - the originator of the lead - a portback acknowledgement using Header (sending the status and email to http://domain2.com/check.php?e=$lead&s=$status for their records). See the code below: ------------------------- Code: [Select] $lead = $_REQUEST['e_mail']; // will grab email from posted url string and assign to local variable $result = mysql_query($command); // this is just to execute the MySQL insert which works just fine but included here to explain validation below // Create API Call string to insert lead into iContact folder $requestURL = "http://domain1.com/insert.php?email=$lead"; // Execute API Call to CAKE $xml = simplexml_load_file($requestURL) or die("feed not loading"); if ($result) { $status = 1; // mark lead as sucess // send postback on lead status header("Location: http://domain2.com/check.php?e=$lead&s=$status"); } -------- Problem: I'm getting all sorts of errors with the simplexml_load_file() function and can't figure out why it won't work. Any input appreciated as this the only way I know how to pass the lead onward and then inform/update the other party of receipt of information. thanks! Hi, Is there a way to send extracted information from one (local) MySQL db, via PHP, to an external web form - having that web form submit that info to it's connected MySQL db without human interaction? Basically, I need to automate a process using the $_GET function to that form but not sure if there is a way to accomplish this from just connecting to the web form (itself); bypassing direct MySQL access which is the later option. Any input appreciated - thanks! Hi guys, I need some help in my coding, I have submitted the form, and basically I should see the success msg, which is echo '<p>Your new account has been successfully created. You\'re now ready to <a href="login.php">log in</a>.</p>'. However it wasnt appearing, and when I look into my database, I couldnt find any record which I have registered, is there something amiss in my coding? Please help, Thanks <?php require_once('123.php'); // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die(mysql_error()); if (isset($_POST['submit'])) { // Grab the profile data from the POST $name = $_POST['name']; $email = $_POST['email']; $password = $_POST['password']; $location = $_POST['location']; $dob = $_POST['dob']; $category = $_POST['category']; $query = "INSERT INTO practice_user (name, email, password, location, dob, category, join_date) " . "VALUES ('$name, $email', $password, $location, $dob, $category, NOW())"; mysqli_query($dbc, $query) or die(mysql_error()); // Confirm success with the user echo '<p>Your new account has been successfully created. You\'re now ready to <a href="login.php">log in</a>.</p>'; mysqli_close($dbc); } ?> Hi, This is my first post, so hopefully, you'll go easy on me. I'm a serious PHP newbie.. I have an form that calls a .php file. The php file is supposed to generate an email made up of the captured form fields and redirect the user to a 'thank you' page. The redirect works, but the email is not being generated. Here is my code: Code: [Select] <?PHP putenv("TZ=US/Central"); $time = date("M j, Y, g:i a"); $name = $_POST["name"]; $email = $_POST["email"]; $phone = $_POST["phone"]; $contact = $_POST["contact"]; $destination = $_POST["destination"]; $resort_brand = $_POST["resort_brand"]; $specific_resort = $_POST["specific_resort"]; $specialty_vacation = $_POST["specialty_vacation"]; $cruise_line = $_POST["cruise_line"]; $cruise_destination = $_POST["cruise_destination"]; $cruise_duration = $_POST["cruise_duration"]; $departDate = $_POST["departDate"]; $number_adults = $_POST["number_adults"]; $number_of_nights = $_POST["number_of_nights"]; $number_children = $_POST["number_children"]; $age1 = $_POST["age1"]; $age2 = $_POST["age2"]; $age3 = $_POST["age3"]; $age4 = $_POST["age4"]; $age5 = $_POST["age5"]; $passport = $_POST["passport"]; $handicapped = $_POST["handicapped"]; $comments = $_POST["comments"]; $recipient = "smarshall@stltoday.com, jmcginnis@post-dispatch.com, info@classictravelstl.com"; $subject = "Classic Travel quote request"; $body = "<p><b>Name:</b> $name<p><b>Email:</b> $email<p><b>Phone:</b> $phone<p><b>Contact:</b> $contact<p><b>Destination:</b> $destination<p><b>Resort Brand:</b> $resort_brand<p><b>Specific Resort:</b> $specific_resort<p><b>Specialty Vacation:</b> $specialty_vacation<p><b>Cruise Line:</b> $cruise_line<p><b>Cruise Destination:</b> $cruise_destination<p><b>Cruise Duration:</b> $cruise_duration<p><b>Departure Date:</b> $departDate<p><b>Number of Adults:</b> $number_adults<p><b>Number of Nights:</b> $number_of_nights<p><b>Number of Children:</b> $number_children<p><b>Age1:</b> $age1<p><b>Age2:</b> $age2<p><b>Age3:</b> $age3<p><b>Age4:</b> $age4<p><b>Age5:</b> $age5<p><b>Passport:</b> $passport<p><b>Handicapped:</b> $handicapped<p><b>Comments:</b> $comments"; $headers = "From: \"$name\" <$email>\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "X-Mailer: Drupal\n"; $headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $send = mail($recipient,$subject,$body,$headers); header( "Location: http://dmsgroup.co/classic-travel/thank_you.html" ) ; ?> The form that calls this file is he http://dmsgroup.co/classic-travel/request_info.html It was working at one point, but it's not anymore. Also, when it was working, the "specialty_vacation" field (which is a checkbox) would not pull in any data. Do I need to do something different to access checkboxes? Thanks in advance for your help! SteveMTNO Hi, I use the following code to create a select menu from an array of options stored in LISTS.php: include 'LISTS.php'; print('<select id="from" name="from">'); foreach ($langList as $lang) {printf('<option %s>%s</option>', ($from1 == $lang ? 'selected="selected"' : ''), $lang); } echo '</select>'; where LISTS.php includes the following: $langList = array(' ','English', 'French', 'German', 'Dutch', 'Spanish'); This works great, but now I want to do something similar with a checkbox list, where each checkbox has an associated 'onchange' javascript function and I'm getting pretty stuck. My checkbox list is of the following form: Code: [Select] <html> <ul style="height: 95px; overflow: auto; width: 200px; border: 1px solid #480091; list-style-type: none; margin: 0; padding: 0;"> <li id="li1b"><label for="chk1b"><input name="chk1b" id="chk1b" type="checkbox" onchange="function1('chk1b','li1b')">Option1</label></li> <li id="li2b"><label for="chk2b"><input name="chk2b" id="chk2b" type="checkbox" onchange="function1('chk2b','li2b')">Option2</label></li> //etc. </ul> </html> What I want to do is have 'Option1', 'Option2', etc. stored in an array in LISTS.php and have a PHP script that populates the checkbox list accordingly, in a similar manner to my select menu above. I can't work out how to get the ID of the next <li> and the next <input> in the list to go up by one each time, e.g. 'li1b' then 'li2b', 'li3b', etc. Could someone pls help me out? Thanks! Not wanting to 'hijack' another thread, but curious about the error of my ways. Why specifically (and very very clearly as I am OLD fart and totally self taught in php/mysql), why will this not suffice to determine form where POSTED data came? page 1 - form start session create and store a hashed session variable 'who_is_it' (ie hash 1Q9zFrEd) display the form submit to page 2 page 2 start session create a hashed variable $is_it-me (ie hash 1Q9zFrEd) compare $is_it_me with the session variable 'who_is_it' if the camparison == each other obtain, validate, cleanse and store data ELSE not from a vaild source I have some data in a table and some of it is Artist names stored as "Last, First" I need to be able to have the script search weather or not someone types "last, first" or "first last". Any ideas? Here's my code: <html> <head> <title>search script</title> </head> <body> <form name="form" action="search.php" method="get"> <input type="text" name="q" /> <input type="submit" name="Submit" value="Search" /> </form> <?php // Get the search variable from URL $var = @$_GET['q'] ; $trimmed = trim($var); //trim whitespace from the stored variable // rows to return $limit=100; // check for an empty string and display a message. if ($trimmed == "") { echo "<p>Please enter a search...</p>"; exit; } // check for a search parameter if (!isset($var)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } //connect to your database ** EDIT REQUIRED HERE ** mysql_connect("localhost","username","password"); //(host, username, password) //specify database mysql_select_db("mydb") or die("Unable to select database"); //select which database we're using // Build SQL Query $query = "select * from songs where Title like \"%$trimmed%\" or Artist like \"%$trimmed%\" order by Title"; // EDIT HERE and specify your table and field names for the SQL query $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo "<h4>Results</h4>"; echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>"; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<p>You searched for: "" . $var . ""</p>"; // begin to show results set echo "Results"; $count = 1 + $s ; // now you can display the results returned echo "<table border=1>"; while ($row= mysql_fetch_array($result)) { $title = $row["Title"]; $artist = $row["Artist"]; $number = $row["Number"]; echo "<tr><td>$count.)</td><td>$title</td><td>$artist</td><td>$number</td></tr>" ; $count++ ; } echo "</table>"; $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>  "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 20 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?> </body> </html> Hi, I'm trying to retrieve/scrape some information from a website using the class name and the tag name.
Below is the example in VB:
Dim htmL_cat As HTMLDocument Dim objTableL_cat As Object, objDatL_cat As Object, objItemL_cat As Object, objKeyL_cat As Object Dim intRowL_cat As Long Set htmL_cat = New HTMLDocument With CreateObject("MSXML2.XMLHTTP") .Open "GET", "http://www.lelong.com.my/Auc/List/BrowseAll.asp", False .send htmL_cat.body.innerHTML = .responseText End With With htmL_cat Set objTableL_cat = .getElementsByClassName("CatLevel1") 'Find elements with class name first For Each objDatL_cat In objTableL_cat Set objKeyL_cat = objDatL_cat.getElementsByTagName("a") 'Next, find elements with tag name For Each objItemL_cat In objKeyL_cat Sheets("Analytics").Range("E6").Offset(intRowL_cat, 0) = objItemL_cat.innerText intRowL_cat = intRowL_cat + 1 Next Next End With Set htmL_cat = Nothing Set objTableL_cat = Nothing Set objKeyL_cat = NothingHow do I do the same using PHP? Thanks. Hello, stristr('http://www.google.com/', 'google') doesn't work but stristr('http://localhost/test.html', 'sandro') works why is this? and how can I solve this problem? Part of my page is taken from external webpages by preg_match. Since It is a partial section, it contains incomplete tags such as <div>, <span>, etc. Thus, they mix up with my entire page and my </div>, </span> are used for the incomplete tags in the borrowed section. How I can end such tags? or separate this section from the main codes (I mean having an isolated section)? Hi ! I need to pass a lot of variables using GET, and many of them are related, so I was thinking in two options: 1) Pass them as array: Code: [Select] example.php?categories[]=cat1&categories[]=cat2 2) Pass them in a single parameter, and split it in PHP (a custom and simpler serializer) Code: [Select] example.php?categories=cat1|cat2 What do you think is better? (or maybe there is a 3rd option...) The second method seems more readable and short, the first easier to construct and maybe faster because we don't need to "unserialize". But I'm looking for better reasons. I'm thinking in a possible advantage of the first method over the second for SEO, because if Google is smart enough to understand that categories[] are all the same, then can understand that: Code: [Select] example.php?categories[]=cat1&categories[]=cat2is equal to: Code: [Select] example.php?categories[]=cat2&categories[]=cat1I think that is more difficult for Google to understand that with: Code: [Select] example.php?categories=cat1|cat2and Code: [Select] example.php?categories=cat2|cat1 Regards!! Enrique. Basically I am trying to make a list of items which I have put into an sql database. When I click on an item in the list, I want a "generic" page loaded, with the items description. Im having alot of trouble with getting this generic page to work. Heres what Ive done so far. The page with shows the list http://pastebin.com/PE8FkyYQ http://pastebin.com/GiCpV5AH The generic page with the items description. http://pastebin.com/HFnSfqN4 http://pastebin.com/C0zsHpZY If anyone can help me solve this problem, ill be greatly in there debt! Hello, How can I get the id in the search bar into the viewuser.php file ... <?php foreach($myObjectMap as $key => $item): ?> <tr> <td> <a href="viewuser.php?id=<?PHP echo $item->ID; ?>"> <?PHP echo $item->UserName; ?> </td> ...
Hello all, I can't get the data store in the $ART_ID variable to pass into the database. The original $Artisan variable is set up like this: 1. Artisan Name. So the explode is taking just the number. If I put an echo after the explode and the $ART_ID variable it outputs the correct information but it doesn't store in the database as that data. The query is in correct order too. Thanks in advance. $CType_Type = $_REQUEST["CTYPE_Type"]; $Artisan = $_REQUEST['Artisan']; $Quantity = $_POST['Quantity']; $HAnswer1 = $_POST["HAnswer1"]; $HAnswer2 = $_POST["HAnswer2"]; $HAnswer3 = $_POST["HAnswer3"]; $HAnswer4 = $_POST["HAnswer4"]; $break = explode(".", $Artisan); $ART_ID = $break[0]; if(!$Quantity) { die('Quantity field is empty. Please enter the quantity of handicrafts made.'); } else { $ctypeQuery = mysql_query("SELECT CTYPE_ID FROM CraftType WHERE CTYPE_Type = '".$CType_Type."'"); while($row = mysql_fetch_array($ctypeQuery)) { $CTYPE_ID = $row["CTYPE_ID"]; $sql = ("INSERT INTO Handicraft VALUES (`HANDI_ID`, '".$Quantity."', 'NULL', '".$CTYPE_ID."', '".$ART_ID."', 'NULL', '1')"); if(!mysql_query($sql)) { die('Error inserting Handicraft Type into table: ' . mysql_error()); } else { -----data in this section doesn't affect the rest of the code---- } } } Please tell me how can i do it ??
I'm pulling data from an xml file and I'm getting a lot of duplicates. How can I remove the duplicates from the query? Code: [Select] foreach($xml->category->subcategory as $category){ echo $category[id]; }//end foreach
Hi,
URL: http://statistik.innebandy.se/ft.aspx?scr=playercareer&fplid=182506 $data = file_get_contents($url); $dom = new domDocument; @$dom->loadHTML($data); $dom->preserveWhiteSpace = false; $tables = $dom->getElementsByTagName('table'); $rows = $tables->item(2)->getElementsByTagName('tr'); print_r($rows[0]); foreach ($rows as $row) { $cols = $row->getElementsByTagName('td'); }
This i what i want: This is a sample html code i have to work with: Code: [Select] <div class="spaceit_pad"><span class="dark_text">English:</span> Fullmetal Alchemist: Brotherhood</div><div class="spaceit_pad"><span class="dark_text">Synonyms:</span> Hagane no Renkinjutsushi (2009), Fullmetal Alchemist (2009), FMA</div><div class="spaceit_pad"><span class="dark_text">Japanese:</span> 鋼の錬金術師</div> I want to extract Specifically these lines: 1) Code: [Select] Fullmetal Alchemist: Brotherhood2) Code: [Select] Hagane no Renkinjutsushi (2009), Fullmetal Alchemist (2009), FMA3) Code: [Select] 鋼の錬金術師 from that, and all this is loaded from a thrid party website, like wikipedia. please help? I'm trying to send some POST data to a page and then get the contents of it. The page is not on my server, so I can't use Sessions or GET. Google hasn't provided me with a definite answer. How would I do this? When I use PHP to gain data from another webpage I usually use file_get_contents Is there a faster way to retrieve data from webpages faster since it only seems to do around 200 website line retrievals per minute? Is cURL faster? Thank you |