PHP - Executing A Php Routine When Clicking A Link
I have a PHP application where I am trying to execute a PHP routine when the user clicks on a link to go to another page. The routine needs to execute before I use a header location command to send the user to the next location. I can't do this all with JavaScript, but it could be part of the solution if necessary. I'd prefer to just use PHP if I could, but I'm not sure that this is possible.
Can anyone share with me a brief example of how I could do this? Thanks! Similar TutorialsHi
I'm trying to change an image when a certain link is clicked. The image is a logo of a company and the links that will be clicked is english, arabic, and Chinese.
So if someone clicks on Chinese then the logo changes to the Chinese version of the normal logo.
Here is my html
<?php $langArabic=''; $langChinese=''; $langSpanish=''; $langEng=''; $linkArabic=getSEOLink($page_id); $linkChinese=getSEOLink($page_id); $linkSpanish=getSEOLink($page_id); $linkEng=getSEOLink($page_id); $queryLink = mysql_query("SELECT * FROM $_SEO_TABLE WHERE `id_page`='".$page_id."'"); if(mysql_num_rows($queryLink) > 0){ $resultLink = mysql_fetch_object($queryLink); if($resultLink->url != ''){ $linkEng = $_HTTP_ADDRESS."".$resultLink->url; if($page_id == 1 || $page_id == '1'){ $linkEng = $_HTTP_ADDRESS; } } if($resultLink->url_arabic != ''){ $linkArabic = $_HTTP_ADDRESS."".$resultLink->url_arabic; } if($resultLink->url_chinese != ''){ $linkChinese = $_HTTP_ADDRESS."".$resultLink->url_chinese; } if($resultLink->url_spanish != ''){ $linkSpanish = $_HTTP_ADDRESS."".$resultLink->url_spanish; } } switch (urlExtension()) { case 'html': $langClass = ''; $langEng='langActive'; $langTag='en'; break; case 'ar': if($page->title_arabic == ''){ $langClass = '_arabic'; }else{ $langClass = '_arabic'; } $langArabic='langActive'; $langTag='ar'; break; case 'es': $langClass = ''; $langSpanish='langActive'; $langTag='es'; break; case 'cn': $langClass = ''; $langChinese='langActive'; $langTag='cn'; break; default: $langClass = ''; $langEng='langActive'; $langTag='en'; } ?> <a class="main-logo<?php echo $langClass;?>" href="javascript:void(0);"><img src="<?php echo $_HTTP_ADDRESS;?>images/logo-letters.png" /></a> <div class="language-selection-wrapper<?php echo $langClass;?> overlay-bg<?php echo $langClass;?> border-bottom-white<?php echo $langClass;?> padding-level-one<?php echo $langClass;?>"> <div class="language-inner-wrapper<?php echo $langClass;?>"> <a class="<?php echo $langEng;?>" href="<?php echo $linkEng;?>">English</a><span>|</span> <a class="<?php echo $langArabic;?>" href="<?php echo $linkArabic;?>">العربيّة</a><span>|</span> <a class="<?php echo $langSpanish;?>" href="<?php echo $linkSpanish;?>">Español</a><span>|</span> <a class="<?php echo $langChinese;?>" href="<?php echo $linkChinese;?>">中文</a> <div class="clearboth"></div> </div> Hi.. I have an issue on my project.I want to open a particular page of a PDF file by clicking a hyper link.How should I do it?any idea ? I used the following code <?php header("Content-Type: application/pdf"); $pdfFile="readme.pdf#page=10"; ?> <html> <head> <title>Untitled Document</title> </head> <body> <a href="http://<?php echo $pdfFile; ?>">Click Here</a> </body> </html> But it showing an alert like following File does not begin with '%PDF-' After clicking alert showing a black screen.. can u please send me the entire code? Thanks... So I am trying to execute an sql query by clicking a button or a link. Ultimately I want users to be able to click the "Fav" button and it then fades into "Added to favorites!" (I am building a favorite system which first collects data on page load like userid and itemid and then it needs to send it to the DB after a button is clicked) The fade and stuff is not the most important part now (although a tip on doing that would be awesome) but the most important part is how to get this functional: PHP Code: <?php // Start Favorite System! $user =& JFactory::getUser(); $userid = $user->id; if ($userid == 62) { echo "userID: ".$userid."<p />"; if ($user->guest) {echo "You are a guest<p />";} $itemid = $this->item->id; echo "itemID: ".$itemid."<p />"; $catid= $this->item->category->id; echo "catID: ".$catid."<p />"; $query = "INSERT INTO jos_k2_fav_xref (userID, itemID, catID) VALUES ('$userid', '$itemid', '$catid')"; // Need a way to make this into a button $run = mysql_query($query) or die(mysql_error()); } else {} ?> Currently all the values get stored in the DB as the page is loaded. I however want to be able to click on something to execute that query how do i do that? I read a bunch of stuff on javascript and ajax but it got me nowhere... Help is greatly appreciated! Goal: To have a gallery that downloads images from the folder I previously uploaded to in a previous script. Bug: When I load the page the thumbnail comes up as broken and when I click on the thumbnail to get the bigger picture it comes up with the following error message: "Firefox doesn't know how to open this address, because the protocol (c) isn't associated with any program." <?php include 'db.inc.php'; //connect to MySQL $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); //change this path to match your images directory $dir ='C:/x/xampp/htdocs/images'; //change this path to match your thumbnail directory $thumbdir = $dir . '/thumbs'; ?> <html> <head> <title>Welcome to our Photo Gallery</title> <style type="text/css"> th { background-color: #999;} .odd_row { background-color: #EEE; } .even_row { background-color: #FFF; } </style> </head> <body> <p>Click on any image to see it full sized.</p> <table style="width:100%;"> <tr> <th>Image</th> <th>Caption</th> <th>Uploaded By</th> <th>Date Uploaded</th> </tr> <?php //get the thumbs $result = mysql_query('SELECT * FROM images') or die(mysql_error()); $odd = true; while ($rows = mysql_fetch_array($result)) { echo ($odd == true) ? '<tr class="odd_row">' : '<tr class="even_row">'; $odd = !$odd; extract($rows); echo '<td><a href="' . $dir . '/' . $image_id . '.jpg">'; echo '<img src="' . $thumbdir . '/' . $image_id . '.jpg">'; echo '</a></td>'; echo '<td>' . $image_caption . '</td>'; echo '<td>' . $image_username . '</td>'; echo '<td>' . $image_date . '</td>'; echo '</tr>'; } ?> </table> </body> </html> Any help appreciated. I'm allowing users to upload a file into a directory that is inside of my ftp's root directory(what is the proper term for this area anyway?) Anyway, I am uploading to this folder: Code: [Select] + www.mywebsite.com/ + files/ + images/ - welcome.jpg + system/ - text.txt - index.php + upload/ <-- here, this one right here - an_uploaded_file.zip If I have a php script that downloads from this folder would I need to worry about someone doing something that is not intended? I don't want someone overwriting my index.php with their own. Here is my form.It works fine.Because it is a radio button form, only one variable of the six available is chosen. This variable is echoed in the relevant hidden field. Then when the variable from the hidden field is posted, it is supposed to be converted to one of six specified strings and then posted to the database into column "egroup". The problem I have is that it always goes to the last variable and posts the string "egroup6". I want to break out of the str_replace routine and post the replacement name which matches the sequence of the hidden field selection. How can I rewrite the str_replace routine so that it breaks when it finds the selected variable? The code for the form; Code: [Select] <table width="700" align="center" cellpadding="5"> <form action="adduser2.php" method="post" enctype="multipart/form-data"> <input name="egroup1" type="hidden" value="<?php echo "$group1"; ?>"> <input name="egroup2" type="hidden" value="<?php echo "$group2"; ?>"> <input name="egroup3" type="hidden" value="<?php echo "$group3"; ?>"> <input name="egroup4" type="hidden" value="<?php echo "$group4"; ?>"> <input name="egroup5" type="hidden" value="<?php echo "$group5"; ?>"> <input name="egroup6" type="hidden" value="<?php echo "$group6"; ?>"> <tr> <td colspan="3"><font color="#OO99CC"><?php echo "$errorMsg"; ?> </font></td> </tr> <tr> <td width="200"><div align="right"> <p><br /> Enter Student Name: </div></td> <td width="125"><p><br /> <input name="userId" type="text" value="<?php echo "$studName"; ?>" /> </td> <td width="350"> <input name="userPwd" type="hidden" value="<?php echo "$activatecode"; ?>" /> <font size="-1" color="#006600">(The password </font><font size="+2" color="#0000FF"><?php echo "$activatecode"; ?></font><font size="-1" color="#006600"> has been allocated to this next student. Print out your full list of student passwords <a href="../reports/reports_page.php">here</a>.)</font></td> </tr> <tr> <td></td> </tr> <tr> <td width="200"><div align="right">Allocate this student to <br /> one of these quiz groups:</div></td> <td width="125" colspan="1"><input type="radio" name="userGroup" value="'<?php echo "$group1"; ?>'" /> <?php echo "$group1"; ?><br /> <input type="radio" name="userGroup" value="'<?php echo "$group2"; ?>'" /> <?php echo "$group2"; ?><br /> <input type="radio" name="userGroup" value="'<?php echo "$group3"; ?>'" /> <?php echo "$group3"; ?><br /> <input type="radio" name="userGroup" value="'<?php echo "$group4"; ?>'" /> <?php echo "$group4"; ?><br /> <input type="radio" name="userGroup" value="'<?php echo "$group5"; ?>'" /> <?php echo "$group5"; ?><br /> <input type="radio" name="userGroup" value="'<?php echo "$group6"; ?>'" /> <?php echo "$group6"; ?><br /></td> <td width="350" align="right" ><p><?php echo $bottlinks; ?></td> </tr> <tr> <td><input name="userCollege" type="hidden" value="<?php echo "$school"; ?>" /> <input name="managerId" type="hidden" value="<?php echo "$userid"; ?>" /> <div align="right"></div></td> <td><input type="submit" name="Submit" value="Submit Form" /></td> </tr> </form> </table> When I post the data I use this code; Code: [Select] // Filter the posted variables $studName = preg_replace("/[^A-Z a-z0-9]/", "", $_POST['userId']); $activatecode = preg_replace("/^A-Z a-z0-9]/", "", $_POST['userPwd']); $school = preg_replace("/[^A-Z a-z0-9]/", "", $_POST['userCollege']); $userGroup = preg_replace("/[^A-Z a-z0-9]/", "", $_POST['userGroup']); // variables posted from hidden fields $egroup1 = $_POST['egroup1']; $egroup = str_replace($egroup1, "egroup1", $egroup1); $egroup2 = $_POST['egroup2']; $egroup = str_replace($egroup2, "egroup2", $egroup2); $egroup3 = $_POST['egroup3']; $egroup = str_replace($egroup3, "egroup3", $egroup3); $egroup4 = $_POST['egroup4']; $egroup = str_replace($egroup4, "egroup4", $egroup4); $egroup5 = $_POST['egroup5']; $egroup = str_replace($egroup5, "egroup5", $egroup5); $egroup6 = $_POST['egroup6']; $egroup = str_replace($egroup6, "egroup6", $egroup6); $managerid = preg_replace("/[^A-Z a-z0-9]/", "", $_POST['managerId']); // filter everything but spaces, numbers, and letters Here is the insert statement; Code: [Select] $sql = mysql_query("INSERT INTO users (userId, userPwd, userCollege, userGroup, egroup, managerId, doe) VALUES('$studName','$activatecode','$school', '$userGroup', '$egroup', '$managerid', now())") or die (mysql_error()); I'm tired and want to sleep so my mistakes are getting lots now. Anybody awake that can explain my problem with the code below. <? function directoryToArray($directory, $recursive) { $array_items = array(); $i = "0"; if ($handle = opendir($directory)) { while (false !== ($file = readdir($handle)) && $i < "3") { if ($file != "." && $file != "..") { if (is_dir($directory. "/" . $file)) { if($recursive) { $array_items = array_merge($array_items, directoryToArray($directory. "/" . $file, $recursive)); } } else { $file = $directory . "/" . $file; $array_items[] = preg_replace("/\/\//si", "/", $file); $i++; } } } closedir($handle); } natsort($array_items); return array_reverse($array_items); } $data = directoryToArray('images/screenshot/', TRUE); print_r($data); ?> What I want is for the while loop to stop after 4 hits and exit and give me the return results. But now it continue until readdir end. I am trying to use some php code inside of an html document and it does not work. I have a script.php file that executes perfectly when I try and use it. Here is the code I am currently using: Code: [Select] <?php echo "<title>"; echo "the Homepage!"; echo "</title>"; ?> Any suggestions would be great. I have the following query where $userid is about 100,000 userids separated by commas. Code: [Select] <? $getpostid=mysql_query("SELECT DISTINCT post.username,post.threadid,thread.threadid,thread.forumid from post,thread WHERE post.username='$username' AND post.threadid=thread.threadid AND post.userid IN ($userid) AND thread.forumid IN ($forumids)") or die (mysql_error()); ?>can i just print all the usernames from above result separated by ';' without looping it multiple times? Could someone help me out how to do above in an efficient manner? Hey there, I recently started working on a PHP calculator, I tryed testing it out and the script is not executing... *NOTE* I found the error, I forgot to assign values to the options, all is good now Code: [Select] <?php /* Script Created by: Far Cry Started: August 20th, 2010 10:51 PM PST Completed */ $title = "Calculator"; $form = "<form action='calculator.php' method='POST'> <table> <tr> <td><input name='firstnumber' type='text'></td> </tr> <tr> <td><input name='secondnumber' type='text'></td> </tr> <tr> <td><select name='operation'> <option name='multiply'>*</option> </select></td> </tr> <tr> <td><input name='submitbtn' type='submit' value='Calculate!'></td> </tr> </table> </form>"; if ($_POST['submitbtn']){ $first = ($_POST['firstnumber']); $last = ($_POST['secondnumber']); $operation = ($_POST['operation']); } if ($operation == 'multiply'){ echo"The answer is " . $first * $last . $form; } echo $form; ?> Thanks in advance. OK, so I have the following file that has database functions: <?php function dbDelete($param){ $conDelete = mysql_connect($url,'username','password',true); mysql_select_db('my_db',$conDelete); mysql_query($param,$conDelete); mysql_close(); if(isset($conDelete)){ mysql_close($conDelete); } } ?> I include the above file in a session handling file. But for some reason the new file can't call the above function as follows: <?php include_once 'the above stated file'; function timeOut(){ dbDelete("DELETE FROM acctussessi WHERE acctussessi_usid = '$sessius[0]'"); $_SESSION = array(); setcookie(session_name(),'',time()-4200); session_destroy(); } //CHECK FOR TIMEOUT REQUEST switch($_GET['xyz']){ case 'timeout': timeOut(); header("Location: /?xyz=timedout"); break; case 'logout': timeOut(); header("Location: /?xyz=loggedout"); break; case 'refresh': dbUpdate("UPDATE acctussessi SET acctussessi_time = ".time()." WHERE acctussessi_unid ='".$token."'"); break; } ?> dbDelete isn't being called inside of the TimeOut() function. The only way it works is by doing the following: <?php function timeOut(){ $_SESSION = array(); setcookie(session_name(),'',time()-4200); session_destroy(); } //CHECK FOR TIMEOUT REQUEST switch($_GET['xyz']){ case 'timeout': dbDelete("DELETE FROM acctussessi WHERE acctussessi_usid = '$sessius[0]'"); timeOut(); header("Location: /?xyz=timedout"); break; case 'logout': dbDelete("DELETE FROM acctussessi WHERE acctussessi_usid = '$sessius[0]'"); timeOut(); header("Location: /?xyz=loggedout"); break; case 'refresh': dbUpdate("UPDATE acctussessi SET acctussessi_time = ".time()." WHERE acctussessi_unid ='".$token."'"); break; } ?> But this is annoying and repetitive. What is going on? Thanks in advance. I am playing around with php but the script doesnt execute to the last point and with no error...
What i am trying to do is checking the input of the user and comparing it what is in db and then applying conditions. So i have 2 files. update.php and home.php. home.php is my html form page and i included 'update.php' in it In my update.php, i have these codes
<?php error_reporting(E_ALL); include_once('database.php'); if(isset($_POST['submit'])) { $q = $_GET['q']; $next = $q + 1; if($q == 26) { echo '<h2>You have Completed the Exam.Congrats!!</h2>'; } elseif($q <= 25){ $sql = "SELECT * FROM Students WHERE Email=?"; $stmt = $conn->prepare($sql); $stmt->bind_param('s', $_SESSION['login']); $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_assoc(); $Mark = $row['Mark']; $Correct = $Mark + 1; $Fail = $Mark + 0; $sqlb = "SELECT * FROM Answers WHERE qid = ?"; $stmtb = $conn->prepare($sqlb); $stmtb->bind_param('s', $q); $stmtb->execute(); $resultb = $stmtb->get_result(); $rowb = $resultb->fetch_assoc(); $Answer = $rowb['Answer']; $Pick = $_POST['ans']; if($Pick == $Answer) { $sqld = "UPDATE Students SET Mark=? WHERE Email = ?"; $stmtd = $conn->prepare($sqld); $stmtd->bind_param('ss', $Correct,$_SESSION['login']); $stmtd->execute(); $resultd = $stmtd->get_result(); echo "correct" ; } } else { echo 'Ate'; echo "<script type='text/javascript'>document.location.href='home.php?q='.$next.';</script>"; } }//post submit ?> The else statement doesnt run. so it keeps reloading the same page. Also i want to ask why i keep getting the value of 2 for my $Correct variable stored on the database into column Mark for a single correct question instead of 1. What could be wrong? Lastly, i dont want the script to run if the browser is edited by the user by changing the value of $q from the browser, because i am using get method, is there a way to do that. Please be nice with your comments. Thanks in advance.!!! Hello, PowerShell script stored locally can never be executed after I click on button: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Testing PowerShell</title> </head> <body> <?php // If there was no submit variable passed to the script (i.e. user has visited the page without clicking submit), display the form: if(!isset($_POST["submit"])) { ?> <form name="testForm" id="testForm" action="get-process.php" method="post" /> Your name: <input type="text" name="username" id="username" maxlength="20" /><br /> <input type="submit" name="submit" id="submit" value="Do stuff NowNew" /> </form> <?php } // Else if submit was pressed, check if all of the required variables have a value: elseif((isset($_POST["submit"])) && (!empty($_POST["username"]))) { // Display the alert box echo '<script>alert("Welcome to Geeks for Geeks")</script>'; // Get the variables submitted by POST in order to pass them to the PowerShell script: $username = $_POST["username"]; // Best practice tip: We run out POST data through a custom regex function to clean any unwanted characters, e.g.: // $username = cleanData($_POST["username"]); $psPath = "C:\\Windows\\SysWOW64\WindowsPowerShell\\v1.0\\powershell.exe"; $psDIR = "C:\\TestNew\\"; $psScript = "pscripta.ps1"; $runScript = $psDIR. $psScript; $runCMD = $psPath." ".$runScript." 2>&1"; echo "\$psPath $psPath <br>"; echo "\$psDIR $psDIR <br>"; echo "\$psScript $psScript <br>"; echo "\$runScript $runScript <br>"; echo "\$runCMD $runCMD <br>"; exec( $runCMD,$out,$ret); echo "<pre>"; print_r($out); print_r($ret); echo "</pre>"; } // Else the user hit submit without all required fields being filled out: else { echo "Sorry, you did not complete all required fields. Please go back and try again."; } ?> </body> </html>
Thank you for your help! Hey guys! My current employer contracted someone to create a script for him. (The script itself is to create a serial number for a piece of software) It's just a PHP script that executes a file and retrieves its output. Now I've never worked with exec() in PHP, and I don't have a reliable environment to test it in. I compiled apache2 and php 5.0.4 and set them to run on a Macintosh (10.3.9) in the office, but I'm sure I've missed some crucial setup stage (mainly, I'm missing php.ini. I did a php -i | grep php.ini to find it, and it says it is in /etc/, but when I look in my PHP/etc folder, only pear.conf is there!). PHP and apache both appear to be working fine, though. When I try and run the PHP script that executes the .ELF file, I get a blank page. Is this because I'm running it in OS X? should I be running it in Linux? Also, I don't know how to Enable exec() on my server, or to see if it's enabled. Basically, I just need someone to walk me through the basics of this. The script and executable SHOULD work fine because the contractor got it working fine. Below is the script, and attached is the executable. Thanks! :3 <?php /* inUID = 456890 inSerialNumUID = 123456 inMachineID_s = &6dA-8P@K-Xsq */ $p1 = "456890"; $p2 = "123456"; $p3 = "\&6dA-8P@K-Xsq"; exec("./create_activation_code.elf $p1 $p2 $p3", $output); foreach ($output as $output_str) { echo $output_str."<br>"; } ?> Looking to INSERT a row in a data table and keeping the User on the current page. Will it work like what I have below, or do I need to send it to its own page then return the User back to where he started? What I have below isn't inserting a row. No errors showing. function bookmark_add () { if (isset($_POST['submit'])) { include("/home2/csi/public_html/resources/con.php"); $query = "INSERT INTO a_player_bookmark (bookmark) VALUES ('1')"; $results = mysqli_query($con,$query); echo mysqli_error($con); } $output = '<form name="bookmark_add" method="post" action="" class="bookmark-plus">'; $output .= '<span><input type="submit" name="Bookmark"></span>'; $output .= '</form>'; return $output; }
Hi, I am using cpanel, where i am want to run a php file, to delete the old records, i used cronjob in cpanel to do this. In time columns i have made : * * * * * to execute each and every minute the script.. In the command textbox i have made: /home/server25/public_html/auto_cancel.php in the email box: admin_email@gmail.com I am getting Permission denied to my email address: The error report am getting is : /bin/sh: /home/server25/public_html/auto_cancel.php: Permission denied Please help me to solve this. Thanks, Hello all, I have been working with PHP for almost a year now, so somewhat still new to it all. OK, this may be an Apache issue, but this involves a php script I wrote that tries to execute on pages that do NOT call it (via the include command). So, here is a little info on how I have set things up. I use WAMP Server to test php and MySQL code for myself (for fun and for practice) and for clients and their web sites. I run WAMP Server off of my laptop, so I can code on the go and because it is on my laptop, I decided to create a PHP & MySQL user authentication setup to keep out unwanted visitors, but allow trusted friends and fellow developers to view my work on client web sites. Let's say the authentication script is called "auth.php" and for all of the pages I want private, I include that script at the top of those pages, if the visitor is not logged in, redirect them to the login page, otherwise, let them view the page (provided their permission level is adequate). Now, for the client web sites that I am working on, I do not call auth.php anywhere on those pages. Now, the problem I notice is that when I visited a client's web site that I am working on (on my WAMP Server), I reviewed my Apache error log and it gave me a PHP error stating the following: Code: [Select] Maximum execution time of 60 seconds exceeded in E:\\wamp\\www\\assets\\auth.php on line 3, referer: http://192.168.1.4/Web_Projects/NCCCLP/home.php Of course I am able to view the client web site pages without having to login, however, the auth.php script tries to run nonetheless. So my question is, does anyone know why this is happening and if and how I can stop it? This is not a serious (urgent) issue, but it does clog up my error logs and so forth and I prefer to have as few errors as possible. Plus, I would just like to know why and how it is running without being called. Any and all help is greatly appreciated and if I need to provide anymore details or be more specific, please let me know. Also, if an issue like this has already been solved and I missed that thread, please let me know and have my apologies. Thanks in advance. Hi All Basically I have 4 fields in my database image2, image3, image4, image5 I have an image uploader to upload the files but I need what I need is if image2 is empty put in image3, if image3 is empty put in image4 so far I have this //so first is the query to find the right row which gives the variable $row //now here is what im doing if($row['image2']!==""){ //run this code } elseif($row['image3']!==""){ //run this code } elseif($row['image4']!==""){ //run this code } elseif($row['image5']!==""){ //run this code } Now the problem I'm having is the code that is always executing is the first one of $row['image2'] even if image2 has a value in the database it still runs that code and over writes the field in the database. It never moves on to field 3 or 4. Can someone please tell me if I've done something wrong. I'm not storing the image in the database just the name. Thanks Danny i'm creating a small app for someone who wants to control the content of each page from a DB. effectively it'd be a template file with header, footer, etc all pre-built, and the content area supplied from a TEXT field in a MySQL table - basically the same idea wordpress uses. this is all fine, but a couple pages would require some php - e.g., a list of events or users or articles, whatever, that are managed in different tables. i can do this with eval - something like: Code: [Select] function render_content($string) { ob_start(); eval("?>$string<?php "); $returns = ob_get_contents(); ob_end_clean(); return $returns; } but i wonder if there's a better way. i can probably limit whatever code needs to be executed in include files, so i thought maybe include some arbitrary tag and use regexp to parse it out... maybe modeled after a conditional comment, e.g., Code: [Select] <!--[include]some-file.inc.php--> // or even... <include>some-file.inc.php</include> but, again, not thrilled with the approach, and wondered if anyone had a better idea. i should probably mention that it's not going to be a "content or include" setup - it probably won't be one or the other, exclusively, and is likely to be a mix on those pages that require it - the php might need to appear before, after, or in the middle of whatever arbitrary markup the user happens to supply, e.g. Code: [Select] <h1>This is a list of stuff</h1> <p>Some explanation lorem ipsum dolor sit ahmet.</p> <?php include('some-file.inc.php'); ?> <em>But this caveat applies to the above list.</em> <div> Something totally unrelated. <img src="pic.jpg" /> </div> not sure I explained that very well, but hopefully the concept comes across. TYIA Hi guys, im having a problem, in my phpfile were is generated the action code form the contacts form is giving me a lot of trouble, im receiving a lot of blank emails, first i thiked was bots,im usign a captcha, but then i notice another thing, when i put the name of the file that generates the action in the browser this loads it and send it the black email. How can i prevent for my php action file to dont be loadit in the browser? Here is the code to you guys have a idea <?php $datahora = "DATA: <B>" . date("d/m/y - H:i:s") . "</B><BR><BR>"; foreach ($_POST as $campo => $valor) { if (($campo == 'imageField2_x') or ($campo == 'imageField2') or ($campo == 'imageField2_y') or ($campo == 'distrito') or ($campo == 'subimit_y') or ($campo == 'codigo') or ($campo == 'seguranca')) {}else { if ($valor <> '') { $campo = str_replace("_", " ",$campo); $campos .= strtoupper($campo) . ": <b>" . $valor . "</b><Br>"; } } } $www = "WWW.USA.COM"; $assunto = "CONTACT - USA - " . $www; $conteudo = "CONTACT - USA<br><br>" . $datahora . ($campos) . "<br>" . $www; $para = "madness@hotmail.com"; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "From: USA <info@usa.com>\r\n"; $headers .= "Reply-To: ".$_POST['email']."\r\n"; if ($_POST['codigo'] == $_POST['seguranca']) { if (mail($para,$assunto,$conteudo,$headers) == true){ ?> <script> alert('Sent sucess!'); window.location = 'contact.php'; </script> <? }} ?> Hope for some help |