PHP - Getting Echo To Appear At A Particular Place
I have gleaned a script from modified bits of tutorials and ended up with this:
<td> <form name="input" action="fotw.php" method="post"> <h4>Want a specific film? <input type="text" width="300" name="requests" /> <input type="submit" value="Request" /><input type="hidden" name="thanks" /></h4> </form> </td> <?php $requests = $_POST['requests']; $data = "$requests\n"; $fh = fopen("../filmoftheweek/users.txt", "a"); fwrite($fh, $data); fclose($fh); /*if (???????? HELP!);*/ // request button has been clicked echo "Thanks, I'll see what I can do."; // In the field I have highlighted in red ?> What I want to do is get the Thanks message to print to the right of the request button but, being a total noob because I didn't pay attention at college during any php bits, I have no idea how to go about it. It's just a visual thing really as I know the text file gets written but, disappearing text does little to reassure the user that something has happened. Probably the field won't be any good as a place to get printed but I tried (for hours) on this. Any help would be greatly appreciated. Along with an explanation, doubly so. Many thanks in advance, Paul Note to moderators: CSS is an acronym for Cascading Style..? Sheet/sheets [attachment deleted by admin] Similar Tutorialshello, I want to display the echo ''"; in the right place on my website in changepassword_form.html all messages are written in changepassword.php. how can i move these echo after entering the wrong password or username? changepassword.php <?php ........... //success //change password in db $querychange = mysql_query("UPDATE users SET password='$newpassword' WHERE username='$username'"); session_destroy(); echo 'Password Has Been Changed Successfully !'; //move these } else{ echo('new password doesnt match!'); //move these } } else { die('old password doesnt match!'); //move these } } else { echo ""; include 'changepassword_form.html'; exit(); } } else{ echo 'you must be logged '; } ?> move these echos somewhere to my html code how to do these?? OK, have no idea what's going on... I've done this a million times... why wont this output!?? I must have a major brain meltdown and dont know it yet!!! Code: [Select] <?php // this echoes just fine: echo $_POST['testfield']; // but this wont echo: echo if (isset($_POST['testfield'])) { $_POST['testfield'] = $test; } echo $test; /// or even this DOESNT echo either!: $_POST['testfield'] = $test; echo $test; ?> Hi All, I'm trying to echo the response from an SLA query, the query works and returns the data when I test it on an SQL application.. but when I run it on my webpage it won't echo the result. Please help? <?php $mysqli = mysqli_connect("removed", "removed", "removed", "removed"); $sql = "SELECT posts.message FROM posts INNER JOIN threads ON posts.pid=threads.firstpost WHERE threads.firstpost='1'"; $result = mysqli_query($mysqli, $sql); echo {$result['message']}; ?> So I need to echo a row from my database with php, but where i need to echo is already inside an echo. This is my part of my code: $con = mysql_connect("$host","$username","$password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("main", $con); $result = mysql_query("SELECT * FROM Vendor"); while($row = mysql_fetch_array($result)) { //I need to echo right here .................. but I get a blank page when I try this. Please Help. echo '<option value=$row['vendor_id']>'; echo $row['vendor_id']; echo '</option>'; } mysql_close($con); Result: A Blank page. Thanks in advance! I have a log system that allows 10 logs on each side(Left and right). I am trying to make it so that the left side has the 10 most recent logs, then the right as the next 10. Any ideas? Hi guys, I can't find any code to help me out with this so I was hoping you guys can. I need some PHP jquery/AJAX code that allows me to do the following: Double click a disabled text box, edit the value and on click out (or whatever) it re-disables and makes the chages in the mysql DB automatically. Hope you guys can help me out. Cheers in advance Hi
I try to echo out random lines of a html file and want after submit password to whole content of the same html file. I have two Problems.
1st Problem When I echo out the random lines of the html file I don't get just the text but the code of the html file as well. I don't want that. I just want the text. How to do that?
for($x = 1;$x<=40;$x++) { $lines = file("$filename.html"); echo $lines[rand(0, count($lines)-1)]."<br>"; }I tried instead of "file("$filename.html");" "readfile("$filename.html");" But then I get the random lines plus the whole content. Is there anything else I can use instead of file so that I get the random lines of text without the html code?P.S file_get_contents doesn't work either have tried that one. 2nd Problem: As you could see in my first problem I have a file called $filename.html. After I submit the value of a password I want the whole content. But it is like the program did forget what $filename.html is. How can I make the program remember what $filename.html is? Or with other words how to get the whole content of the html file? My code: if($_POST['submitPasswordIT']){ if ($_POST['passIT']== $password ){ $my_file = file_get_contents("$filename.html"); echo $my_file; } else{ echo "You entered wrong password"; } }If the password isn't correct I get: You entered wrong password. If the password is correct I get nothing. I probably need to create a path to the file "$filename.html", but I don't know exactly how to do that. Hi all, I could do with some help ... What I am trying to do is insert some additional div in the piece of code you will see below, but I've been having some troubles as to what stntax I should be using and where to place those div ... In order to help you help me, I suggest you have a look at this page elhoster2.com/europeshuttle , make a search with country "sweden" as "return trip" . From there you will see 2 results. This is the page I am trying to layout. Basically, the image is on the left and then I would like to have a div floated on the left that will contain the services (multilingual driver , greeting sign etc ), another div with the info seen in bold (passengers =1, charges are per vehicle) and a last div with all pricing info. My issue is that I don't really know how to break this piece of php code to achieve the desire effect ... I hope someone will be kind enough to help me with this. Code: [Select] function get_tours($type,$country,$airport_start,$city_start,$psg,$way){ $mysql=new MYSQL; $q="select * from tours where tour_country ='$country' and tour_airport='$airport_start'and tour_city='$city_start' and tour_standard='$type' and veh_seats >='$psg'"; $res=mysql_query($q,$mysql->connection); if(mysql_num_rows($res)>0){ while($r=mysql_fetch_array($res)){echo'<form id="booking_2" action="booking-form.php" method="post">'; echo'<div class="search-results spacing-bot" ><figure class="img-indent"> <a class="lightbox-image" href="'.SITE.$r['tour_vehicle_picture'].'" data-gal="prettyPhoto[gallery1]"><img src="'.SITE.$r['tour_vehicle_picture'].'" width="188" height="138" alt=""></a></figure> <div class="search-results-info">'; #THIS IS WHERE THE SERVICE LIST BEGINS ########################################### $tour_id=$r['tour_id']; $serv="select * from services_to_tour where tour_id='$tour_id'"; $re=mysql_query($serv,$mysql->connection); while($ro=mysql_fetch_array($re)){ $serv_id=$ro['serv_id']; $this->get_serv($serv_id); } #THIS IS WHERE THE SERVICE LIST ENDS I GUESS AND THAT I WOULD LIKE TO BE IN ITS OWN DIV ########################################### #FROM HERE I AM GETTING A BIT CONFUSED WITH THE PHP AND HAVE NO IDEA HOW TO STYLE IT !!!########################################### $crg_by=$r['tour_price_per']; if($crg_by=='per vehicle'){ $crg='per vehicle'; $tour_price= $r['tour_price'] ; $tour_r=$r['tour_price_return']; $total=$r['tour_price'] + $r['tour_price_return'] ; $total_i=$r['tour_price']; $total_b=$r['tour_price_return']; } elseif($crg_by=='per person'){ $crg='per passenger';$total_i=$r['tour_price'] * $psg; $tour_price= $r['tour_price'] * $psg; $tour_r=$r['tour_price_return']* $psg; $total= $tour_price + $tour_price; } if($way=='Return'){$price='Collection: '.$tour_price.' Euros<br />Return: '.$tour_r.' Euros'; $total=$total; $amount=$total;$percent='15'; $online=$this->get_percent($amount,$percent); $pr=$online;$total='<br />Total Price: '.$total.' Euros<br />Payable online: '.$online.' Euros'; } else{$amount=$tour_price;$percent='15'; $online=$this->get_percent($amount,$percent); $price='Price: '.$tour_price.' Euros<br />Payable online: '.$online.' Euros';$total='';$pr=$r['tour_price']; $pr=$online; } echo'<span class="p1"><strong>Passengers:</strong></span> '.$psg.'<br /><span class="p1"><strong>Charges are by '.$crg.'</strong></span><br /><span class="p1"><strong>Price </strong></span><br />'.$price.$total.'<input type="hidden" name="tour_id" value="'.$tour_id.'" /> <input type="hidden" name="way" value="'.$way.'" /><input type="hidden" name="psg" value="'.$psg.'" /><input type="hidden" name="price" value="'.$pr.'" /><input type="hidden" name="price_in" value="'.$total_i.'" /><input type="hidden" name="price_out" value="'.$total_b.'" /><input type="hidden" name="operator" value="'.$r['operator_id'].'" /><a onClick="document.getElementById(\'booking_2\').submit()" class="button" style="float:right"><strong><strong>book this transfer</strong></strong></a></form> </div> <div class="border-bot"></div> </div>'; } } else{echo'<p>Sorry your search returned no results.</p>';} } I currently have a Javascript placed at the top of the same file as my HTML form. Now I need to run the file as PHP, and was wondering what the proper protocol and best practice is for the JavaScript (which does some client side validation). Can I leave it as is, at the top of the file after changing the extention to PHP. If I put it in a seperate file, should I call it as a JavaScript or as an INCLUDE file. If I INCLUDE it, should the INCLUDE be a PHP file (that contains the JS, or a JS extention. Does any of this make a difference, or will any method work, leaving it to personal preference? Hello, I'm getting my feet wet with PHP and databases. I've read that I can provide the login for a database in a separate file, which I can place in a directory located OUTSIDE of my site (parent folder). This works fine at the isp where my site is being hosted. However, now I want to do the same thing at a site that is hosted at (ugh) GoDaddy. Unfortunately, GoDaddy does not allow access outside of the site (aka parent folder of the site). So now where am I supposed to put the file with the database login info in it so it will be secure? Thank you. What would be the best way to break the following html into a table <div class="highlight">Name: CHRISTOPHER</div> <table summary="This table contains status information for the selected name."> <caption>Selected name status Information</caption> <tr> <th>Current Name:</th> <td>CHRISTOPHER</td> </tr> <tr> <th>Initial Filing Date:</th> <td>DECEMBER 15, 1997</td> </tr> <tr> <th>County:</th> <td>NEW YORK</td> </tr> <tr> <th>Jurisdiction:</th> <td>NEW YORK</td> </tr> <tr> <th>Type:</th> <td>Full Member</td> </tr> Would pregmatch or COMDocument be easier? Greetings once again, My script retrieves variables from a database and pre-populates a form: Code: [Select] <input type="text"" name="First" value="<?php echo stripslashes($row['First']); ?>" > Simple to do with text fields, but not as simple for checkboxes: Code: [Select] <input type="checkbox" name="Subject" size="27" value="Math" checked> In the past I've used JavaScript to place a check in a checkbox, based on the value in the database. Can anyone show me a simple way to use PHP to place the check if the variable found in the database is in fact "Math"; but leave it it unchecked if the Subject value is empty? As always, thank you! ~Wayne Got this working script that sends email via a form:
<?php
$name = $_POST['name'];
} else { }
{ } ?>
Problem is, I want a bar to appear saying 'Message Sent. We Will Contact You Shortly'. I'm brand new to php and followed a tutorial for the above. It's a simple form that I understand, apart from the code needed for confirmation! Please can someone offer any assistance. Thanks in advance......
I need a way to find numbers 0000-9999 where no number has more than 2 digits in the same place in common. I know PHP but this is a little beyond me, can anyone help? I have a membership directory that I've been working with for a long time, and recent server upgrades with MySQL, PHP, etc. forced me to do some recoding. While I was doing that, I wanted to try and make some improvements. I must give a brief description of the intent, and then the results I got, so someone can sort out the problem for me. I have a query that selects all "Agent" members, then orders them by County, then by Company Name. What I am trying to do is create a new heading in my list every time the County information changes as the list is sorted and output to my table.
I am going to attache 2 .php files with my code. The agent_member_list.php is the original code that pulls all of the members properly, and results can be viewed he http://www.nmlta.org...member_list.php
The agent2_member_list.php is where I'm trying to insert the new conditional statement to print my County headings when a new County is encountered in the results. The heading actually works, and changes correctly, but the problem is that the first member entry in every county is not printed in the output. I know the query is correct, so I'm sure I've got the conditional "if" for checking County field wrong, or misplaced. Here is the link to it: http://www.nmlta.org...member_list.php
I'm hoping someone can spot my error pretty quickly, I only dabble in this very rarely. Thanks for any help!
Attached Files
agent2_member_list.php 5.06KB
3 downloads
agent_member_list.php 4.82KB
2 downloads I want to create many PDF pages by using a PDF document template that uses place holders
The data would come from a CSV file
I've looked into a solution for the above for a couple of years now!
I haven't found anything that would do the trick for me
It seems as though PDF and PHP don't go well - especially if I want to use a template with place holders
Just looking for suggestions
Thanks
EDIT: forget PDF... is it possible to use something else? Like a Word doc??
OM
Edited by OM2, 05 June 2014 - 09:07 PM. Hiya peeps! I have this code; if(preg_match('([0-9]{5})', $this->_searchString)) { echo '5 characters, numbers only.'; } elseif(preg_match('([0-9]{7})', $this->_searchString)) { echo '7 characters, numbers only.'; } The 7 characters are not working for some reason, I have used this preg_match regex all over my script and it's working everywhere else but with this? Can anyone see any reason why it is not working? Many thanks, James. I have recently started a Wordpress Site (www.edsstudios.com). Let me say in advance I am a designer and not a coder, hence the need to come to this forum. I installed a theme which I would like to customize on the home page. I want to place three images along with text below the image slider of the theme. I have included an attachment (pic1.jpg) showing the photoshop mock of how I want the home page to look. Keep in mind I only want to add the image below the image slider. The rest of the page is already existing as part of the wordpress theme. So, I sliced up only the images from the photoshop mock(pic2.jpg) within photoshop and produced the web ready images and html code. I opened the home.php file but can't get the code to function. Below is the code for the home.php page first. Below that is the html code for the images. Can someone tell me if there is something wrong with the code for the images along with where to place it on the home.php file? Home.php CODE <!-- --><?php get_header(); ?> <div id="contenthome"> <div id="slider"> <p> <?php include(TEMPLATEPATH."/includes/slider.php");?> </p> </div> <div id="homepage"> <div class="homepageright"> <div id="subscribe" class="widget"> <h4><span><?php _e("Subscribe", 'organicthemes'); ?></span></h4> <p><?php _e("Receive news and updates from us.", 'organicthemes'); ?></p><form action="http://feedburner.google.com/fb/a/mailverify" method="post" target="popupwindow" onsubmit="window.open('http://feedburner.google.com/fb/a/mailverify?uri=<?php echo ot_option('feedburner'); ?>', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true"><input type="text" value="Enter your email address..." id="subbox" onfocus="if (this.value == 'Enter your email address...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter your email address...';}" name="email"/><input type="hidden" value="<?php echo ot_option('feedburner'); ?>" name="uri"/><input type="hidden" name="loc" value="en_US"/><input type="submit" value="Subscribe" id="subbutton" /><input type="hidden" value="eNews Subscribe" name="title"/></form> </div> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Home Sidebar') ) : ?> <div class="widget"> <h4>Widget Area</h4> <p>This section is widgetized. To add widgets here, go to the <a href="<?php echo admin_url(); ?>widgets.php">Widgets</a> panel in your WordPress admin, and add the widgets you would like to <strong>Homepage Top Right</strong>.</p> <p><small>*This message will be overwritten after widgets have been added</small></p> </div> <?php endif; ?> </div> <div class="homepageleft"> <h3><?php echo cat_id_to_name(ot_option('hp_cat')); ?></h3> <?php $recent = new WP_Query("cat=" .ot_option('hp_cat'). "&showposts=" .ot_option('hp_num') ); while($recent->have_posts()) : $recent->the_post();?> <div class="postarea"> <div class="posttitle"> <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2> <a class="commenticon" href="<?php the_permalink(); ?>#comment" title="Comments"><?php comments_number('0', '1', '%'); ?></a> </div> <div class="homecontent"> <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail( 'home-thumbnail' ); ?></a> <p><?php the_excerpt(); ?></p> <p><a class="more-link" href="<?php the_permalink() ?>">Read More</a></p> </div> </div> <?php endwhile; ?> </div> </div> </div> <!-- The main column ends --> <?php get_footer(); ?> IMAGES CODE <html> <head> <title>home page icons</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script type="text/javascript"> <!-- function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> </head> <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('images/home-page-icons_05ro.png','images/home-page-icons_07ro.png','images/home-page-icons_09ro.png')"> <!-- ImageReady Slices (home page icons.psd) --> <table width="960" height="183" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01"> <tr> <td colspan="3"> <img src="images/home-page-icons_01.png" width="310" height="143" alt=""></td> <td colspan="3"> <img src="images/home-page-icons_02.png" width="332" height="143" alt=""></td> <td colspan="3"> <img src="images/home-page-icons_03.png" width="318" height="143" alt=""></td> </tr> <tr> <td> <img src="images/home-page-icons_04.png" width="223" height="39" alt=""></td> <td><div align="center"><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image19','','images/home-page-icons_05ro.png',1)"><img src="images/home-page-icons_05.png" name="Image19" width="66" height="39" border="0"></a></div></td> <td colspan="2"> <img src="images/home-page-icons_06.png" width="273" height="39" alt=""></td> <td><div align="center"><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image20','','images/home-page-icons_07ro.png',1)"><img src="images/home-page-icons_07.png" name="Image20" width="65" height="39" border="0"></a></div></td> <td colspan="2"> <img src="images/home-page-icons_08.png" width="248" height="39" alt=""></td> <td><div align="center"><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image21','','images/home-page-icons_09ro.png',1)"><img src="images/home-page-icons_09.png" name="Image21" width="62" height="39" border="0"></a></div></td> <td> <img src="images/home-page-icons_10.png" width="23" height="39" alt=""></td> </tr> <tr> <td> <img src="images/spacer.gif" width="223" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="66" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="21" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="252" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="65" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="15" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="233" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="62" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="23" height="1" alt=""></td> </tr> </table> <!-- End ImageReady Sl This has been bothering me for a while, how do I do this? echo (" <form method = 'get' action = 'member.php?action=Search&option=faction&name=NAME'> Faction's Name: <input type='text' name='member' /><br /><br /> <input type='submit' value='Search' /> </form> "); name='member' is supposed to be sent with he member.php?action=Search&option=faction&name=NAME. Obviously replacing NAME with the input. |