In the event search, the query searches only by the Event Name:
sample http://graph.facebook.com/search?q=party&type=event
Is there a way to query the Event Description? Or other fields ?
I tried to use until or since, but i get the same results
https://graph.facebook.com/search?q=party&type=event&until=today
https://graph.facebook.com/search?q=party&type=event&until=yesterday
FQL only accept search by event ID
The search returns the id's for all events returned in the search. Using https://graph.facebook.com/search?q=party&type=event&until=today&fields=id you can loop the id results to https://graph.facebook.com/eventid?access_token=yourapptoken to get array of the event which will include the description, name, image etc;
Live Sample for Page & Event Search here: http://shawnsspace.com/plugins/plugins.searcher.php
Refer to: http://developers.facebook.com/docs/reference/api/event/
Example Code: Assumes PHP-SDK 3.1.1 is installed on page.
Events https://graph.facebook.com/search?q=conference&type=event
<?php
$qi = urlencode($_GET['qs']);
if(!$_GET['qs']){
$qi = urlencode($_POST['qs']);
if(!$_POST['qs']){
$qi = "party";
}
}
$search = $facebook->api('/search?q='.$qi.'&type=event&limit=10');
foreach ($search as $key=>$value) {
$i=1;
foreach ($value as $fkey=>$fvalue) {
$i++;
if($fvalue[id]=="h"){
}else{
$id = $fvalue[id];
$searchResp = $facebook->api('/'.$id.'');
$name = $searchResp[name];
$location = $searchResp[location];
$desc = $searchResp[description];
$sTime = $searchResp[start_time];
$eTime = $searchResp[end_time];
echo $name. '<br />';
echo $location. '<br />';
echo $sTime. '<br />';
echo $eTime. '<br /><hr />';
}
};
};
?>
<form id="getsearch" method="post" action="yourpage.php">
<input type="text" value="" name="qs" id="searchbox" onclick="this.value='';" style="padding: 2px;" size="48">
<input type="submit" value="Search" style="padding: 3px;">
</form>
The search in Graph API for events is currently limited to the event name only; I don't believe there are plans to change this in the short term, unfortunately
Related
Im using Semantic UI for design and some functionalities and I failed to make multiple value posting in dropdown select - it adds blocks into the select input, but when submitting, posts only numeric string - one of the input values (instead of array). Seems to post the highest number from selection.
Can anyone tell me, how to make it working? (loading previous values works perfect);
<select class="ui dropdown" id="subjs" name="subj" multiple>
<?php
$selected = $cats->getsubj();
$subs = $cats->getsubj(true);
if (isset($subs) && count($subs) > 0)
for ($i = 0; $i < count($subs); $i++) {
$opt = (in_array($subs[$i], $selected)) ? ' selected="selected"' : '';
?>
<option class="subjs" value="<?php echo $subs[$i]['ID']; ?>" <?php echo $opt; ?>><?php echo $subs[$i]['title']; ?></option>
<?php
}
?>
</select>
JS:
<script>
$('.ui.dropdown').dropdown({
maxSelections: 2
});
</script>
PHP:
var_dump($_POST);
the script is listing of categories from database into select as options. Value for each option is it's ID (integer). One article may be liked with more than one category
All advices apreciated... Thanx
Well for all, who make stupid mistakes, simple add '[]' to the multiple select name parameter to post array.
<select name="x[]"></select>
I am wondering how I can differentiate the name on the input box in a while loop so when I post I get 2 separate values. Here is my code:
<form method="post" action="rewarded.php">
<?php
$nameqry="SELECT name FROM kids";
$names=mysqli_query($conn, $nameqry) or die ("Error could not execute name query: " . mysqli_error());
echo "<table>";
while($namerow=mysqli_fetch_array($names)) {
$name=$namerow["name"];
echo "<tr><td>$name will use <input type='text' name='points'> points.</td></tr>";
}
echo "</table>";
echo "<input type='submit' value='Submit'>";
?>
</form>
while($namerow=mysqli_fetch_array($names)) {
$name=$namerow["name"];
echo "<tr><td>$name will use <input type='text' name='points-<?php echo $name; ?>'> points.</td></tr>";
}
each time the code repeated in loop it gives you a different input name.
also you can use name="points[]"
it will return all names in a array
You could make the name a variable and change the variable on each loop.
$input_name_count = 1;
while($namerow=mysqli_fetch_array($names)) {
$name=$namerow["name"];
echo "<tr><td>$name will use <input type='text' name='".$input_name_count."'> points.</td></tr>";
}
Alternatively, if you don't want to use numbers (i.e. points1, points2, etc.or 1,2,3 etc.) make a list of names that you want.
$names_list = ['name', 'name 2', 'hippos'];
Then simply select the item you want from the list using a counter.
$counter = 0;
while($namerow=mysqli_fetch_array($names)) {
$name=$namerow["name"];
echo "<tr><td>$name will use <input type='text' name='".$names_list[$counter]."'> points.</td></tr>";
$counter++;
}
I'm migrating from codeigniter to Fat-Free (F3) and trying to get my head around the quirks.
Regarding the following form:
<form ACTION = "<?php echo $_SERVER['PHP_SELF'];?>" METHOD="POST">
<input type="text" name="theirName" value="" required="required">
...
In standard PHP I get the POST value like this:
$name = $_POST['theirName'];
Or in codeignitor:
echo form_open('someclass/some_method_of_someclass');
$name = $this->input->post('name');
How do I get data from a form in a view in f3/fatfree?
You can get it from the Hive:
$name = $f3->get('POST.name');
i am displaying the daily report submitted by the user now i want to mail the same to email when the send email button is clicked. how can i do that in PHP ?
i used the following code
extract($_REQUEST);
if(isset($send_mail)){
$edata= $_POST['send_msg'];
echo "<script type='text/javascript'>alert('$edata');</script>";
$ka_semail=$_SESSION['user_email'];
$subject = "Report";
$body = $edata;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Info <'.$ka_semail.'>' . "\r\n";
$mchk= mail($ka_semail, $subject, $body, $headers);
if(isset($mchk)){
echo "<script type='text/javascript'>alert('Your data Sent sucessfully');</script>";
header("location:reports.php");
}
}
?>
<body>
<div id="main">
<header>
<div id="logo">
<div id="logo_text">
<a href="index.html">
<div style="background:#2A0000"><img src="images/kreamsoftlogo.png"/></a></div>
</div>
</div>
<?php include'nav.php'; ?>
</header>
<div id="site_content">
<div id="email-data">
<div id="content">
<div class="content" style="min-height:385px; width: 100%" >
<h1>Daily Report </h1>
<?
$current_date = date("d/m/Y");
$current_user = $_SESSION['user_login'];
$find = mysql_query("select * from k_dailyreport where kr_user='$current_user' AND kr_date='$current_date'");
?>
<div class="content_item">
<ul>
<?php
$numrow=mysql_num_rows($find);
if($numrow>0){
$sino = 0;
echo "<table border='0' width='100%'>";
echo "<tr class='head'>";
echo "<th>S.No</th>";
echo "<th>Project</th>";
echo "<th>Process</th>";
echo "<th>Process Date</th>";
echo "<th>Current Duration</th>";
echo "</tr>";
$sno=0;
while($row = mysql_fetch_array($find)){
$sno=$sno +1;
$sino++;
$cls = ($sino%2==0) ? "even" : "odd";
echo "<tr class='t1'>";
echo "<td>$sno</td>";
echo "<td>".$row['kr_project']."</td>";
echo "<td>".$row['kr_process']."</td>";
echo "<td>".$row['kr_rtime']."</td>";
echo "<td>".$row['kr_ctime']."</td>";
}?></td>
<?php
echo "</tr>";
?><form name="test" method="post"enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];?>">
<p style='padding-top: 15px;margin-right: 50px; float:right'><input class='submit' id="sendEmail" type="submit" name='sendmail' value='Send Mail' />
<input type="hidden" name="send_mail" value="send_mail" />
<input type="hidden" name="send_msg" value="<?php
$numrow=mysql_num_rows($find);
if($numrow>0){
$sino = 0;
echo "<table border='0' width='100%'>";
echo "<tr class='head'>";
echo "<th>S.No</th>";
echo "<th>Project</th>";
echo "<th>Process</th>";
echo "<th>Process Date</th>";
echo "<th>Current Duration</th>";
echo "</tr>";
$sno=0;
while($row = mysql_fetch_array($find)){
$sno=$sno +1;
$sino++;
$cls = ($sino%2==0) ? "even" : "odd";
echo "<tr class='t1'>";
echo "<td>$sno</td>";
echo "<td>".$row[1]."</td>";
echo "<td>".$row[2]."</td>";
echo "<td>".$row[3]."</td>";
echo "<td>".$row[3]."</td>";
echo "</tr>";
}echo "</table>";}?>" /></p>
</form>
<?
}else{
?>
<center><img style="text-align:center" src="images/no_record.gif" /></center>
<?
}
echo "</table>";
?>
</li>
</ul>
</div>
</div> </div>
</div>
</div>
i want to mail the entire table with data
Without knowing anything about your code, I can perhaps at least guess as to the structure of what builds this table. Maybe something along the lines of this?:
writeTableHeader();
foreach ($values as $value) {
writeTableRow($value);
}
writeTableFooter();
Maybe even abstracted into its own higher-level function?:
function writeTable($values) {
$result = '';
$result .= buildTableHeader();
foreach ($values as $value) {
$result .= buildTableRow($value);
}
$result .= buildTableFooter();
return $result;
}
Any such function or abstraction can be used to construct the HTML for the email body as well...
// ... previously building the overall email body
$mailBody .= writeTable($values);
// ... maybe some more email body elements as well
mail($to, $subject, $mailBody);
Styling the email will be another story, of course. It's best not to rely on linked resources in an HTML email, those tend not to be requested by mail clients as they're often abused by spammers and the like. You can perhaps include the style sheet(s) as an "embedded resource" in the email, though in most cases I think inline styling is probably best for emails. (Some mail clients might not even load an embedded resource, at least not without first prompting the user, which isn't an ideal user experience.)
Assuming you don't want to duplicate much code, the above method can be abstracted using the Form Template Method refactoring pattern (example here, among others).
I guess the point I'm getting at is that the email doesn't send the web page, but rather the web page and the email are both independent "views" of the underlying data. Common code between them can be abstracted and shared of course, but trying to re-use a webpage itself in an email is over-complicating the situation.
I have a contact form which is a template for pages on wordpress that I use if I need a contact form. All works fine but I want to add the capability of adding a file attachment so when the user fills in their name etc they can upload a photo and that photo will be sent to be me as an attachment.
I have a perfect working contact form and I only want to add that functionality to it. All my current code does all this it sends the name of the person their email address and their message to my email, all I'm missing is the attachment feature. I've been looking at alot of contact forms with this feature but to integrate that feature to my sendmail.php seems very hard as the coding style is completely different. Here is a demo of this in action. demo
This is my php file that has the form in it.
<?php get_header(); ?>
<script type="text/javascript">
$(document).ready(function(){
$('#contact').ajaxForm(function(data) {
if (data==1){
$('#success').fadeIn("slow");
$('#bademail').fadeOut("slow");
$('#badserver').fadeOut("slow");
$('#contact').resetForm();
}
else if (data==2){
$('#badserver').fadeIn("slow");
}
else if (data==3)
{
$('#bademail').fadeIn("slow");
}
});
});
</script>
<!-- begin colLeft -->
<div id="colLeft">
<!-- Begin .postBox -->
<div class="postBox">
<div class="postBoxTop"></div>
<div class="postBoxMid">
<div class="postBoxMidInner first clearfix">
<h1>Contact Us</h1>
<p><?php echo get_option('alltuts_contact_text')?></p>
<p id="success" class="successmsg" style="display:none;">Your email has been sent! Thank you!</p>
<p id="bademail" class="errormsg" style="display:none;">Please enter your name, a message and a valid email address.</p>
<p id="badserver" class="errormsg" style="display:none;">Your email failed. Try again later.</p>
<form id="contact" action="<?php bloginfo('template_url'); ?>/sendmail.php" method="post">
<label for="name">Your name: *</label>
<input type="text" id="nameinput" name="name" value=""/>
<label for="email">Your email: *</label>
<input type="text" id="emailinput" name="email" value=""/>
<label for="comment">Your message: *</label>
<textarea cols="20" rows="7" id="commentinput" name="comment"></textarea><br />
<input type="submit" id="submitinput" name="submit" class="submit" value="SEND MESSAGE"/>
<input type="hidden" id="receiver" name="receiver" value="<?php echo strhex(get_option('alltuts_contact_email'))?>"/>
</form>
</div>
</div>
<div class="postBoxBottom"></div>
</div>
<!-- End .postBox -->
</div>
<!-- end colleft -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
and here is the file that handles the sending of the mail.
<?php
if(isset($_POST['submit'])) {
error_reporting(E_NOTICE);
function valid_email($str)
{
return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*#([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
}
if($_POST['name']!='' && $_POST['email']!='' && valid_email($_POST['email'])==TRUE && strlen($_POST['comment'])>1)
{
$to = preg_replace("([\r\n])", "", hexstr($_POST['receiver']));
$from = preg_replace("([\r\n])", "", $_POST['email']);
$subject = "Website contact message from ".$_POST['name'];
$message = $_POST['comment'];
$match = "/(bcc:|cc:|content\-type:)/i";
if (preg_match($match, $to) ||
preg_match($match, $from) ||
preg_match($match, $message)) {
die("Header injection detected.");
}
$headers = "From: ".$from."\r\n";
$headers .= "Reply-to: ".$from."\r\n";
if(mail($to, $subject, $message, $headers))
{
echo 1; //SUCCESS
}
else {
echo 2; //FAILURE - server failure
}
}
else {
echo 3; //FAILURE - not valid email
}
}else{
die("Direct access not allowed!");
}
function hexstr($hexstr) {
$hexstr = str_replace(' ', '', $hexstr);
$hexstr = str_replace('\x', '', $hexstr);
$retstr = pack('H*', $hexstr);
return $retstr;
}
?>
Thanks!
You can read this simple tutorial to know what needs to be done to add file upload support to your current form:
http://www.tizag.com/phpT/fileupload.php
Hope it helps!
EDITED
After the upload process, you can do like this:
if (file_exists($_FILES['uploaded']['tmp_name'])) {
$mail->AddAttachment($_FILES['uploaded']['tmp_name'], $_FILES['uploaded']['name']);
}
What this does is to add an attachment to your email by calling the AddAttachment from PHPMailer, and using the file just uploaded from the TMP folder of your server... so no actual storage of the file is necessary.
You can use
http://wordpress.org/plugins/contact-form-7/
It has a option for Upload field as well as all validations, really easy to use.
You just need to enter shortcode and you can use the contact form anywhere you want.