Trying to add contact form - php

Been working on this a bit and somewhat dificult with my limited skills. I created the area so far but adding the contact form is proving to be a huge challenge for me.
This is the area so far:
The grey area is where I would like the contact form to go, something like this:
What I would like the contact form to achive:
Add the (Ask a Question)
Person using contact form has to input Name,email, and telephone before contact agent button allows to be sent.
Info box to default message: I'm interested in the Post address but they can always override by typing in their own message.
Contact message will be sent to whatever the above email address is populated (right now it's mine up there joe#teamambrose.realtor
below the Contact Agent button show: By sending a request you agree to our Privacy Policy.
Here is where I am so far on the code:
<!--======= Agent Info =========-->
<section class="info-property agents-info">
<h5 class="tittle-head"><?php esc_html_e('agent details', 'realtor');?></h5>
<div class="inner">
<!--======= AGENT DETAILS =========-->
<div class="row">
<div class="col-sm-3">
<?php echo wp_get_attachment_image(_sh_get_attachment_id_from_src(sh_set($meta1, 'agent_img')), '270x288');?>
</div>
<div class="col-sm-9">
<?php $term_list = wp_get_post_terms(get_the_id(), 'property_agent', array("fields" => "names")); ?>
<h5><?php echo implode( ', ', (array)$term_list );?></h5>
<!--======= SOCIAL ICONS =========-->
<ul class="social_icons">
<li class="facebook"><i class="fa fa-facebook"></i></li>
<li class="twitter"><i class="fa fa-twitter"></i></li>
<!--<li class="googleplus"><i class="fa fa-google-plus"></i></li>-->
<!--<li class="linkedin"><i class="fa fa-linkedin"></i></li>-->
<li class="instagram"><i class="fa fa-instagram"></i></li>
</ul>
<p><?php $description = $agents_term[0]->description; echo $description;?></p>
<!--======= AGENT INFOR =========-->
<ul class="agent-info">
<li>
<p><i class="fa fa-phone"></i> <?php echo sh_set($meta1, 'phone');?> </p>
</li>
<li>
<p><i class="fa fa-envelope-o"></i><span style='font-size:11px'><?php echo sh_set($meta1, 'email');?></span></p>
</li>
<li>
<p><i class="fa fa-home"></i> <?php printf( esc_html__('Listed %s Properties', 'realtor'), sh_set(sh_set($agents_term, 0 ) , 'count' ) );?> </p>
</li>
</ul>
</div>
</div>
<div class="overlay">
<div class="container">
<h1><?php echo balanceTags($title);?></h1>
<div class="pull-left"><?php echo balanceTags($title);?> </div>
<h5>
<div style="text-align: center;">
<?php echo 'Learn More: ' . get_the_title();?> </div>
</h5>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<div style="height: 400px; width: 300px; background-color: #f8f8f8; border: 1px solid #dddddd;">
</div>
</div>
<div class="col-sm-8">
<div style="max-height: 400px; overflow: hidden; max-width: 610px; padding-left: 43px;">
<?php the_post_thumbnail('337x271', array('class' => 'img-responsive', 'style' => 'transform: translate(0%, -10%)'));?>
</div>
</div>
</div>
</section>
Any help on this will be awesome!

Figured it out on my own. Had to wrap all the echo commands from tutorial in php

Related

Unable to send data from one file to another file

i have created a php page in which i want that whenever i refresh the page it should shuffle and in that data i want that whenever i click on data it should redirect to a new page where that data should be displayed for this I have used Session to store it.
home.php
<?php
$con = new mysqli("localhost","root","","writersplanet");
$sql = "SELECT * FROM books ORDER BY RAND()";
$execute = mysqli_query($con,$sql);
while ($row = mysqli_fetch_assoc($execute)) {
$_SESSION['uploadcoverimg'] = $row['uploadcoverimg'];
$_SESSION['bookname'] =$row['bookname'];
$_SESSION['uname'] =$row['uname'];
$_SESSION['summary'] =$row['summary'];
$_SESSION['thoughts'] =$row['thoughts'];
$_SESSION['pdf'] = $row['pdf'];
$_SESSION['date'] = $row['date'];
echo "<div class='container' align='center'>
<a href='readbook.php'>
<div class='box'>
<div class='imgbox'>
<img src='upload/".$row['uploadcoverimg']."'>
</div>
<div class='content'>
<h3>".$row['bookname']." <i class='fas fa-chevron-circle-right'></i>".$row['uname']."</h3>
<p>".$row['summary']."</p>
</div>
</div>
</a>
<div class='outcome'>
<div class='heart'>
<i class='fas fa-heart'></i>
</div>
<div class='eye'>
<i class='fas fa-eye'></i>
</div>
<div class='ratings'>
<i class='fas fa-star-half-alt'></i>
</div>
</div>
<div class='scrollmenu1'>
<a href='#home' style='border-radius: 10px;margin-top: 10px; background-color: black;color: white; width: 65px;height: 30px;box-sizing: border-box;'>Horror</a>
<a href='#news' style='border-radius: 10px;margin-top: 10px; width: 65px;height: 30px;box-sizing: border-box; background-color: #0a3da3;color: white;'>Sci-Fi</a>
<a href='#contact' style='border-radius: 10px;margin-top: 10px; background-color: #ff69b4;color: white; width: 65px;height: 30px;box-sizing: border-box;'>Love</a>
</div>
<div class='content1'>
<h2>Time</h2>
<p><br>
Writers Thoughts about this book:
".$row['thoughts']."
</p>
</div>
</div>";
}
?>
In my sql code I have used [id, uname, bookname, summary,thoughts,uploadcoverimg,pdf,date].
readbook.php
<img class='bookcover' src='Desert.jpg'>
<div class='heading'>
<h3><?php echo $_SESSION['bookname']; ?> <i class='fas fa-chevron-circle-right'></i><?php echo $_SESSION['uname'];?></h3>
</div>
<div class='container'>
<div class="half_star">
<i id='half_star' class='fas fa-star-half-alt'></i>
</div>
<div class="comment">
<i id='comment' class='fas fa-comments'></i>
</div>
<div class="like">
<i id='like' class='fas fa-thumbs-up'></i><br>
</div>
<div class="date">
<i id='date' class='fas fa-calendar-alt'></i><br>
<?php echo $_SESSION['date'];?>
</div>
<div class="share">
<i id='share' class='fas fa-share'></i>
</div>
<div class='scrollmenu1'>
<a class='horror' href='#home' color='white'>Horror</a>
<a class='sci-fi' href='#news'>Sci-Fi</a>
<a class='love' href='#contact'>Love</a>
</div>
</div>
<div class='summary'>
<h1>Summary of the Book</h1>
<p><?php echo $_SESSION['summary'];?></p>
</div>
<div class="thoughts2">
<h2 class="quotes_head">Thoughts of the Writer</h2>
<p><?php echo $_SESSION['thoughts'];?></p>
</div>
<div class="storyhead">
<h1>Let's start the story:</h1>
</div>
<div class="taskbar">
<button class="bookmark"><i id="bookmark" class="fas fa-bookmark"></i>Bookmark</button>
<button class="unlock"><i id="unlock" class="fas fa-unlock"></i>Unlock</button>
<button class="download">Download</button>
</div>
<div class="pages">
click here!
<iframe src="upload/<?php echo $_SESSION['pdf'];?>" width="1000px" height="500px"></iframe>
</div>
If anybody can help me then its a great thank you from my side because this is related to my career planning.
Thank You
Use this function:
https://www.php.net/manual/en/function.http-build-query.php
instead of this:
$_SESSION['uploadcoverimg'] = $row['uploadcoverimg'];
$_SESSION['bookname'] =$row['bookname'];
$_SESSION['uname'] =$row['uname'];
$_SESSION['summary'] =$row['summary'];
$_SESSION['thoughts'] =$row['thoughts'];
$_SESSION['pdf'] = $row['pdf'];
$_SESSION['date'] = $row['date'];
use this:
$query_string = http_build_query($row);
change a href url so you append '?$query_string' to the URL
<a href='readbook.php?<?php echo $query_string?>'>
and in your readbook.php use $_GET[] instead of $_SESSION[];
There are some limitation on how long a query string can be, but in your case, I think you have small enough dataset to pass.
Your solution done properly would be using a MySQL connection in the readbook.php while you would pass only a book id from the previous page so that you can select info for the exact book from the database using a query with where clause (i.e. select * from books where book_id = x).

Dynamic bootstrap tabs using php and mysql

I have Bootstrap modal tabs and it is works fine without data loop. I am trying to fill tabs using data from db(fetch), but it is not working when i am changing tabs, how can call my required tab data on press to my tab? I know that I have problem with looping or maybe "active"- class of tabs. Here is my code. What is wrong?
<div class="row">
<div class="col">
<div class="row">
<div class="col-sm-4">
<h4 class="mb-4">Ölkələr</h4>
</div>
</div>
<div class="row">
<?php
$conn = connect_to_bd();
mysqli_set_charset($conn,"utf8");
$selectolke = mysqli_query($conn, "Select t.ID as tid,t.text_az as textaz, c.textid as textid, c.olkeflag as olkeflag, c.id as cid, c.country_az as country_az from countries c, text t where t.id = c.textid");
while($selectolkerow = mysqli_fetch_array($selectolke))
{
$textid = $selectolkerow["textid"];
$country_az = $selectolkerow["country_az"];
$olkeflag = $selectolkerow["olkeflag"];
$olkeid = $selectolkerow["cid"];
?>
<div class="col-lg-4">
<div class="tabs tabs-vertical tabs-left tabs-navigation">
<ul class="nav nav-tabs col-sm-3">
<li class="nav-item active">
<a class="nav-link" href="#tabsNavigation<?php echo $textid; ?>" data-toggle="tab"><img src="lib/png/<?php echo $olkeflag; ?>.png"> <?php echo $country_az; ?></a>
</li>
</ul>
</div>
</div>
<div class="col-lg-8">
<div class="tab-pane tab-pane-navigation active" id="tabsNavigation<?php echo $textid; ?>">
<h4><?php echo header_subname_olke_select_az($olkeid); ?></h4>
<p class="notworkingcss" style="color: #fff;font-family:Verdana, sans-serifsans-serif;text-shadow: black 1px 1px 2px;font-size: 1.2em;">
<?php echo text_olke_select_az($textid, $olkeid); ?>
</p>
<div class="row portfolio-list lightbox m-0" data-plugin-options="{'delegate': 'a.lightbox-portfolio', 'type': 'image', 'gallery': {'enabled': true}}">
<div class="col-12 col-sm-6 col-lg-3">
<div class="portfolio-item">
<span class="thumb-info thumb-info-lighten thumb-info-centered-icons">
<span class="thumb-info-wrapper">
<img src="img/products/yerli/1.jpg" class="img-fluid" alt="Et mehsullari">
<span class="thumb-info-action">
<a href="img/products/yerli/1.jpg" class="lightbox-portfolio">
<span class="thumb-info-action-icon thumb-info-action-icon-light"><i class="fa fa-search-plus"></i></span>
</a>
</span>
</span>
</span>
</div>
</div>
<div class="col-12 col-sm-6 col-lg-3">
<div class="portfolio-item">
<span class="thumb-info thumb-info-lighten thumb-info-centered-icons">
<span class="thumb-info-wrapper">
<img src="img/products/yerli/2.jpg" class="img-fluid" alt="Et mehsullari">
<span class="thumb-info-action">
<a href="img/products/yerli/2.jpg" class="lightbox-portfolio">
<span class="thumb-info-action-icon thumb-info-action-icon-light"><i class="fa fa-search-plus"></i></span>
</a>
</span>
</span>
</span>
</div>
</div>
<div class="col-12 col-sm-6 col-lg-3">
<div class="portfolio-item">
<span class="thumb-info thumb-info-lighten thumb-info-centered-icons">
<span class="thumb-info-wrapper">
<img src="img/products/yerli/3.jpg" class="img-fluid" alt="Et mehsullari">
<span class="thumb-info-action">
<a href="img/products/yerli/3.jpg" class="lightbox-portfolio">
<span class="thumb-info-action-icon thumb-info-action-icon-light"><i class="fa fa-search-plus"></i></span>
</a>
</span>
</span>
</span>
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>

How to Exclude a selected and highlighted post from displaying among rest of the posts

I have custom post type of doctors. When the name is clicked it will take to the single page of the doctor. Below there is a small div which displays a number of posts. I dont want the post which is already displayed at the top to be at the bottom.
this is the code i have done:
<?php foreach($dr as $doc){ ?>
<div class="col-md-4">
<img src="<?php echo get_the_post_thumbnail_url($doc->ID);?>" class="img-reposive img-circle dc-img mb50" alt="" />
</div>
<div class="col-md-8">
<div class="dr-single-box">
<h3 class="dr-single-tile"><?php echo $doc->post_title; ?></h3>
<div class="sub-tile"><?php echo get_post_meta($doc->ID,'Department',true); ?></div>
<div class="dc-single-social">
<p><?php echo $doc->post_content; ?></p>
make an appointment
<div class="row">
<div class="col-md-4">
<h3 class="mb10">Qualifications</h3>
<p><?php echo get_post_meta($doc->ID,'Qualifications',true); ?></p>
</div>
the bottom portion looks like this :
<?php $arg=array('post_type'=>'doctors','post_status'=>'publish','posts_per_page'=>4,'offset'=>1) ;
$doctor_data=get_posts($arg);
/*var_dump($doctor_data);*/ ?>
<div class="lightbg ptb80">
<div class="container">
<div class="row">
<div class="col-lg-12 col-md-12">
<h1 class="heading-title">Doctors</h1>
</div>
</div>
<div class="row">
<?php foreach($doctor_data as $doctor) { ?>
<div class="col-lg-3 col-md-3">
<div class="dc-style-box">
<img src="<?php echo get_the_post_thumbnail_url($doctor->ID); ?>" class="img-responsive" alt="Doctor 1" />
<div class="dc-style-inner">
<ul>
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-google-plus"></i></li>
</ul>
<h5><?php echo $doctor->post_title; ?></h5>
<span><?php echo get_post_meta($doctor->ID,'Department',true);?></span>
</div>
</div>
</div>
can anyone shed some light to guide me ? ?
<?php
$cur = get_the_ID();
$arg=array('post_type'=>'doctors','post_status'=>'publish','posts_per_page'=>4,'offset'=>1, 'post__not_in' => $cur) ;
$doctor_data=get_posts($arg);
/*var_dump($doctor_data);*/ ?>
<div class="lightbg ptb80">
<div class="container">
<div class="row">
<div class="col-lg-12 col-md-12">
<h1 class="heading-title">Doctors</h1>
</div>
</div>
<div class="row">
<?php foreach($doctor_data as $doctor) { ?>
<div class="col-lg-3 col-md-3">
<div class="dc-style-box">
<img src="<?php echo get_the_post_thumbnail_url($doctor->ID); ?>" class="img-responsive" alt="Doctor 1" />
<div class="dc-style-inner">
<ul>
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-google-plus"></i></li>
</ul>
<h5><?php echo $doctor->post_title; ?></h5>
<span><?php echo get_post_meta($doctor->ID,'Department',true);?></span>
</div>
</div>
</div>
Hi, You should add 'post__not_in' to exclude current post to be fetched in second loop. Try this code. Let me know if you need any more assistance.
Thanks.
According to your comment you wish to display random posts therefore use below $arg instead of yours.
$arg = array('post_type'=>'doctors',
'post_status'=>'publish',
'posts_per_page'=>4,
'offset'=>1,
'orderby' => 'rand'
);

Tabs - Content shown after clicking one of the tab (Bootstrap)

Well, as the title says, I am not able to display the content in the tabs.
What I am doing is I am fetching the data from MySQL table and displaying it in tabs (successfully fetched).
What I am facing the problem is when the page is done with loading, I have to click one of the tabs in order to display all the contents of the tabs.
Here's the code for the tabs:
<div class="tabbable">
<ul class="nav nav-tabs">
<li class="active">
Description
</li>
<li>
Terms and Conditions
</li>
<li>
Returns and Cancellation
</li>
</ul>
<div class="tab-content">
<div class="tab-pane" id="description">
<p class="lead text-justify" style="margin: 10px 5px;">
<?php echo $descrip; ?>
</p>
</div>
<div class="tab-pane" id="terms">
<p class="lead text-justify" style="margin: 10px 5px;">
<?php echo $termsAndCond; ?>
</p>
</div>
<div class="tab-pane" id="returns">
<p class="lead text-justify" style="margin: 10px 5px;">
<?php echo $returnsAndCan; ?>
</p>
</div>
</div>
</div>
The data is displayed once clicked on either of the tabs from the code above. I don't know where I have made the mistake. Kindly help me out in rectifying it.
Thank You in advance.
Next to setting the Description tab active which you did by setting <li class="active"> you also have to set the Description tabs content active. I think you forgot to do this.
Add the class active to the first tab-pane, so change it from <div class="tab-pane" id="description"> into <div class="tab-pane active" id="description">.
See http://getbootstrap.com/javascript/#tabs for more documentation about Bootstraps tab component.

Using Simple HTML Dom to Scrape Google SERP

I am looking to scrape the HTML response for a Google SERP using Simple HTML Dom I need it split into Google Ads, Google Local Listings and normal SERPS the html is below;
Local SERP
<div style="padding-bottom:8px">
<div class="vsc vscl" data-extra="ludocid=14796923074808088664&lumarker=A" sig="zoG">
<div data-ved="0CDkQkgowAA">
<div data-ved="0CDoQkQowAA"> </div>
</div>
<!--m-->
<div class="g" style="padding-top:2px;line-height:18px">
<div style="width:318px;float:left">
<h3 class="r" style="line-height:normal"><a class="l" href="http://www.beaucare.co.uk/" onmousedown="return rwt(this,'','','','1','AFQjCNH2k6BS0xRb2CTmI-lrSbmEXI1F6Q','','0CDsQoAIwAA','','',event)">Beaucare <em>Dry Cleaners</em></a></h3>
<span><cite class="_Ed">www.beaucare.co.uk</cite></span><br>
<div style="display:inline-block;margin-right:5px"><span style="margin-right:5px" class="rtng">3.8</span><span class="star star-s"><span style="width:56px"></span></span></div>
<span style="white-space:nowrap">6 Google reviews</span></div>
<div style="margin-left:26px;width:22px;float:left"><span style="height:38px;padding:0;width:22px"><a class="l" style="border:none;display:block;overflow:hidden;height:30px;width:16px" href="https://maps.google.co.uk/maps?pws=1&num=100&igu=1&ip=0.0.0.0&safe=images&gl=uk&gll=53.41058,-2.97794&gws_rd=ssl&um=1&ie=UTF-8&q=dry+cleaners+twickenham&fb=1&hq=dry+cleaners&hnear=0x48760c93b240c7c3:0xe4a25f60c77e7ed1,Twickenham,+Greater+London&cid=14796923074808088664&sa=X&ei=4731U6_DFurV0QWM1IHoBw&ved=0CD8QrwswAA"><span class="lumi0 lupin" style="display:block;background:url(/images/mappins_grey.png) no-repeat;background-position:0 -35px;background-size:;height:30px;width:16px"></span></a></span></div>
<div style="width:146px;float:left;color:#808080;line-height:18px"><span>146 Heath Rd</span><br>
<span>Twickenham</span><br>
<nobr><span>020 8891 5797</span></nobr></div>
<!--n--></div>
</div>
</div>
Paid SERP
<li class="ads-ad" data-hveid="34">
<h3><a style="display:none" href="http://www.google.co.uk/aclk?sa=L&ai=C-QrY4731U4TTGYm4jAb3q4HwCsWV_qMF9can5boBtI6yLggAEAEoAlD06tiLAWC7vq6D0ArIAQGpAvwJat3my7s-qgQmT9CoSc8LXNEiEfFMf0izXjjIVgr6InoeWMZFZsdEobDCsi4h-PKAB72KqSaQBwGoB6a-Gw&sig=AOD64_2ShDv4EEWhKvQJU3p6FF4V1mqfyg&rct=j&q=&ved=0CCMQ0Qw&adurl=http://ducanerichmond.co.uk/" id="s0p1"></a><b>Dry Cleaning</b> Services - We <b>Dry Clean</b> all types of material‎</h3>
<div class="ads-visurl"><span class="ads-badge">Ad</span><cite>www.ducanerichmond.co.uk/</cite>‎
<div class="action-menu ab_ctl"><a class="_Su ab_button" href="#" id="am-b-1398152331" aria-label="Result details" aria-expanded="false" aria-haspopup="true" role="button" jsaction="ab.tdd;keydown:ab.hbke;keypress:ab.mskpe" data-ved="0CCQQ7B0"><span class="mn-dwn-arw"></span></a>
<div class="action-menu-panel ab_dropdown" role="menu" tabindex="-1" jsaction="keydown:ab.hdke;mouseover:ab.hdhne;mouseout:ab.hdhue" data-ved="0CCUQqR8">
<ul>
<li class="action-menu-item ab_dropdownitem" role="menuitem" data-type="why_this_ad">
<div class="action-menu-button" role="menuitem" tabindex="-1" jsaction="am.itemclk" data-ved="0CCYQgRM">Why this ad?</div>
</li>
</ul>
</div>
</div>
<span class="_ME">020 8332 1111</span></div>
<div class="ads-creative">Leather,Suede,Fur,Silk,& Upholstery</div>
<div class="_Fbb">
<div class="_WE"><span class="_YE"></span></div>
<div class="_WE">Westminster House, Kew Road, Richmond, Surrey‎</div>
</div>
</li>
Standard SERP
<li class="g"><!--m-->
<div class="rc" data-hveid="87">
<h3 class="r">Kings <em>Dry Cleaners</em>, <em>Twickenham</em> | Dry Cleaners - Yell</h3>
<div class="s">
<div>
<div class="f kv _UD" style="white-space:nowrap"><cite class="_Ed">www.yell.com/biz/kings-<b>dry</b>-<b>cleaners</b>-<b>twickenham</b>-4477896/</cite>
<div class="action-menu ab_ctl"><a class="_Su ab_button" href="#" id="am-b4" aria-label="Result details" aria-expanded="false" aria-haspopup="true" role="button" jsaction="ab.tdd;keydown:ab.hbke;keypress:ab.mskpe" data-ved="0CFkQ7B0wBA"><span class="mn-dwn-arw"></span></a>
<div class="action-menu-panel ab_dropdown" role="menu" tabindex="-1" jsaction="keydown:ab.hdke;mouseover:ab.hdhne;mouseout:ab.hdhue" data-ved="0CFoQqR8wBA">
<ul>
<li class="action-menu-item ab_dropdownitem" role="menuitem"><a class="fl" href="http://webcache.googleusercontent.com/search?q=cache:fKpsx3qZnjcJ:www.yell.com/biz/kings-dry-cleaners-twickenham-4477896/+&cd=5&hl=en&ct=clnk&gl=uk" onmousedown="return rwt(this,'','','','5','AFQjCNF_iMCDBEJfF9L_3mW57Z3Tqp0-xg','','0CFsQIDAE','','',event)">Cached</a></li>
<li class="action-menu-item ab_dropdownitem" role="menuitem"><a class="fl" href="/search?pws=1&igu=1&gl=GB&gll=53.41058,-2.97794&near=liverpool&q=related:www.yell.com/biz/kings-dry-cleaners-twickenham-4477896/+dry+cleaners+twickenham&tbo=1&sa=X&ei=4731U6_DFurV0QWM1IHoBw&ved=0CFwQHzAE">Similar</a></li>
</ul>
</div>
</div>
</div>
<div class="f slp"><span class="csb" style="display:inline-block;position:relative;top:1px;background:url(/images/nav_logo195.png) no-repeat -100px -260px;height:13px;width:65px"><span class="csb" style="background:url(/images/nav_logo195.png) no-repeat -100px -275px;height:13px;width:39px"></span></span> Rating: 3 - ‎2 votes</div>
<span class="st"><span class="f">22 Jul 2014 - </span>Find Kings <em>Dry Cleaners</em> in <em>Twickenham</em> on Yell. Get reviews, opening hours and directions .</span></div>
</div>
</div>
<!--n--></li>
I have tried using the following code
foreach($html->find('li .g') as $e) {
echo $e->innertext . '<br><br>';
}
But this does not show any results, I have also searched for ->find('h3 .r') but I still get no result.

Categories