PHP - Newby Needs Your Help - Easy Php :d
Ok so this is what I am looking for and I cannot seem to find any documentation on it!
I have some html files which I want to call up by using the following: engine.php?id=? with the questionmark being 1,2,3,4,5,6, etc... where each number is a different HTML page, I just want it to look a little cleaner then if I just have it redirect to each page itself I mean come on what looks better: http://localhost/engine.php?id=1 <------ http://localhost/home.html Any guidance is welcome. Thanks, Drew Similar TutorialsHei, please can anyone help me? I guess it's done with if function - i can be wrong too. :/ I want to get about the same "step by step" stuff.. Look example: http://p6lva.eu/site/realinfo.php I tried by my own, but I failed too much : <?php $nick = $_GET['nick']; $server = $_GET['server']; $teenus = $_GET['teenus']; if (!empty($nick) && $server === null) { echo "<center>Choose server:<br><br>\n <a href='realinfo.php?server=1&nick=$nick' style='text-decoration: none;'><button style='width: 250px; text-align: left;'><center>\n Server 1</center></button></a> </center>"; } else { echo ""; } if (!empty($server) && $teenus === null) { include "service1.php"; } else { echo "show frontpage"; } if (!empty($teenus)) { if ($teenus === vip && $server === 1) { include "vip.php"; } if ($teenus === admin && $server === 1) { include "admin.php"; } } else { echo "You must choose service!!! Or this service doesnt in our database!!!"; } if (isset($nick) || isset($server) || isset($teenus)) { // if not added one of the values - like $server, $nick or $teenus then show frontpage echo ""; } else { include 'frontpage.php'; } ?> HELP Hello. Assuming that I have two variables: $exURL=@$HTTP_REFERER; $goodURL = 'http://www.SomeSite/login/'; How can I check if the two URLs match each other? Regards hmmmm my last post got deleted due to my naughty url:-( Anyway its not spam :-( hear is my real problem. I HAVE this form in a iframe in a drupal site.....I followed many tutorials but it seems fine? It keeps downloading the actual php file instead of posting to my email? form code/////////////// <form action="EnquirySend.php" method="post" enctype="application/x-www-form-urlencoded" name="Enquiry_Form" target="_self" id="Enquiry_Form"> <div class="demo"> <div id="Col1"> <p>Date Departing:</p> <p>Date Returning</p> <p>Name<span style="font-size: 16px; "><span style="color: rgb(255, 0, 0); ">*</span></span> : </p> <p>Phone<span style="font-size: 16px; "><span style="color: rgb(255, 0, 0); ">*</span></span> : </p> <p>Email:<span style="font-size: 16px; "><span style="color: rgb(255, 0, 0); ">*</span></span> : </p> <input name="button" type="submit" class="demo" id="button" value="Submit your Enquiry"> </div> <div id="fieldsAline"> <input name="departing_Date" type="text" id="departingDate"></p> <p> <input type="text" id="returnDate"></p> <p> <input maxlength="20" name="name" size="20" style="cursor: default; " type="text" /></p> <p> <input maxlength="20" name="phone" size="20" style="cursor: default; " type="text" /></p> <p> <input maxlength="30" name="email" size="20" style="cursor: default; " type="text" /></p> </div> <p><div id="Col2"> <div id="topCol2"><p>Number Travelling: <span style="font-size: 16px; "><span style="color: rgb(255, 0, 0); ">*</span> <input maxlength="2" name="number" size="3" type="text" value="1" /> PostCode :<input name="postcode" type="text" id="postcode" size="5" maxlength="5"> </p> <p>Can we help you with any extras?</p> <p> <textarea name="extras" id="extras" cols="45" rows="3">Are you interested in 5 star accommodation? </textarea> </p> <p> Which Holiday Package are you interested in <span style="font-size: 16px; "><span style="color: rgb(255, 0, 0); ">*</span></span> ? <br><br> <label> <input type="radio" name="package" value="radio" id="manila"> <span style="color:#0CF">Manila</span></label> <label> <input type="radio" name="package" value="radio" id="manila_boracay"> <span style="color:#0CF">Manila & Boacay</span></label> <br> <label> <input type="radio" name="package" value="radio" id="Manila_angeles"> <span style="color:#0CF">Manila & Angeles</span></label> <label> <input type="radio" name="package" value="radio" id="Manila_Cebu"> <span style="color:#0CF">Manila & Cebu</span></label> <br> <br><br> </p></div></div></div> </form> HERE IS THE RESPONDER PHP FILE CODE/////////// <?php //--------------------------Set these paramaters-------------------------- // Subject of email sent to you. $subject = 'Enquiry_Form '; // Your email address. This is where the form information will be sent. $emailadd = 'sales@hotasiantour.com'; // Where to redirect after form is processed. $url = 'www.hotasiantour.com'; $departing_Date = $_REQUEST['departingDate'] ; $returning_Date = $_REQUEST['returningDate'] ; $Name = $_REQUEST['name'] ; $Phone = $_REQUEST['phone'] ; $Email = $_REQUEST['email'] ; $Number_comming = $_REQUEST['number'] ; $postcode = $_REQUEST['postcode'] ; $Any_extras = $_REQUEST['extras'] ; $holiday_package = $_REQUEST ['package'] ; // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty. $req = '0'; // --------------------------Do not edit below this line-------------------------- $text = "Results from form:\n\n"; $space = ' '; $line = ' '; foreach ($_POST as $key => $value) { if ($req == '1') { if ($value == '') {echo "$key is empty";die;} } $j = strlen($key); if ($j >= 20) {echo "Name of form element $key cannot be longer than 20 characters";die;} $j = 20 - $j; for ($i = 1; $i <= $j; $i++) {$space .= ' ';} $value = str_replace('\n', "$line", $value); $conc = "{$key}:$space{$value}$line"; $text .= $conc; $space = ' '; } mail($emailadd, $subject, $text, 'From: '.$emailadd.''); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; // -----------------------auto responder-------------------------- $responseSubject = "Your request has been received"; $responseMessage = "Hello,\n\nThanks for submitting your request. One of our agents will be in contact with you shortly.\n\nKind regards,\nYour Company"; $responseFromName = "Hot Asian Tours"; $responseFromEmail = "sales@hotasiantour.com"; mail($fromEmail, $responseSubject, $responseMessage, "From: ".$responseFromName." <".$responseFromEmail.">"); ?> Hi, I've inherited a website with a problem! Basically the site runs pommo mailing list, which has worked fine for years. Recently though the website domain name changed. Since then - or at least at a similar time - pommo has just stopped working completely. It does nothing but outputs blank pages. I've never done any php development so I've no idea where to start in terms of debugging this. I've checked that the files etc all exist on the server: they do. I've uploaded a test html page which works. I've uploaded a test php page containing: <?php phpinfo( ); ?> and it works. But when I visit any page in the pommo application, the browser just renders a totally empty white page - no source HTML at all, just nothing! Can anyone suggest how to debug this? Even an error message would be somewhere to start. Thanks all! ob_start(); include('file.php'); $content = ob_get_clean(); ok so this is the code i found for adding a file to a variable.. now how would i use it in term of this: <?php $id = NULL; if(isset($_GET['id']) && $_GET['id'] == "1"){ $id = 'Marc'; } else if(isset($_GET['id']) && $_GET['id'] == "2"){ $id = 'Glenn'; } else if(isset($_GET['id']) && $_GET['id'] == "3"){ $id = 'Nathan'; } else if(isset($_GET['id']) && $_GET['id'] == "4"){ $id = 'Scott'; } ?> ok so the get variable checks to see whose id youve requested. then when for example id = 4 i want to display an include file somewhere else on the page so i would use.. <?php echo $id; ?> now insted of it being "nathan" i want it to be a file i didnt really understand the first code i found Easy One - What is the symbol for or? Example: && = and, right? What is 'or'? Hey guys, I'm dealing a url that is similar to hxxp://domain/directory/?#{$id}. What I'm trying to do is extract $id from that. Its not available as a $_GET variable and $_SERVER['REQUEST_URI'] comes up as "/directory/?". Does anyone know how I could retrieve $id ? Thanks I am trying to send an html file (with .js formatting) to the browser from within a PHP script. The .js formatting is not being interpreted and so the result in the browser is less than impressive. Why can't I make a call, in PHP, to a url and have the results from that call directed to the browser? OK below is my code. the values for $row['state'] are in this format "AL - Alabama" its got the space in it. Code: [Select] while($row = mysql_fetch_array($result)) { echo "<option value=" . $row['state'] . '">' . $row['state']; } ?> When i run the script it outputs HTML as this Code: [Select] <option value="AL" -="" alabama"="">AL - Alabama</option> As you can see at the space it terminates and puts the " in. Im assuming this is a rookie programming mistake. Please help, Justin Right now I'm working on a simple register form and I have included the theme. I set up a div and positioned the div below the register form to output any error in red text. If I were to use code like this if(empty($_POST['username']) || empty($_POST['password']) || empty($_POST['email']) || empty($_POST['Veremail'])){ $required_info = "All three fields are required to continue!"; } It will not work, because I don't have a die(); or end(); function, so it will display: " All three fields are required to continue! and You have been successfully registered! " BUT IT'S IN THE CORRECT PLACE UNDER THE FORM WHERE I PLACED THE DIV. So I made this change if(empty($_POST['username']) || empty($_POST['password']) || empty($_POST['email']) || empty($_POST['Veremail'])){ $required_info = die("All three fields are required to continue!"); } and it worked fine, but now, the words are not positioned under the form, but at the bottom of the page, I'm wondering how I would end that script, but align the text so it displays underneath the form, and not at the bottom of the page? If you don't understand ask me please. Hello! I am trying to make a Guestbook with help from the internet. I have created all sites what i need, but i have some problems with the Input. For example here is the Name inputfrom the "sign.php" <form id="form1" name="form1" method="post" action="addguestbook.php"> <td> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td width="117">Name</td> <td width="14">:</td> <td width="357"><input name="name" type="text" id="name" size="40" /></td> </tr> And here is the "insert sequence" from the "guestbook.php": $sql="INSERT INTO $tbl_name(name, email, comment, datetime) VALUES('$name', '$email', '$comment', '$datetime')"; $result=mysql_query($sql); If i open the guestbook.php i just can see the datetime. What went wrong? Thanks, Mark p.S.: sorry for my english. I'm just learning php and I've created a test shopping website. Everything is working well, but I need help with the following: This is my products table in the database: "CREATE TABLE products ( id int(11) NOT NULL auto_increment, product_name varchar(255) NOT NULL, price varchar(16) NOT NULL, details text NOT NULL, category varchar(16) NOT NULL, subcategory varchar(16) NOT NULL, date_added date NOT NULL, PRIMARY KEY (id), UNIQUE KEY product_name (product_name) ) "; I have 3 subcategories: Hats, Pants and Shirts. On my index page I have links to these three items. This is my products.php code. When run it shows all the items in the 3 subcategories. How do I change the code so that this page display only the Hats when someone clicks on the Hats link? <?php // Connect to the MySQL database include "storescripts/connect_to_mysql.php"; $dynamicList = ""; $sql = mysql_query("SELECT * FROM products ORDER BY subcategory DESC"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount > 0) { while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $product_name = $row["product_name"]; $price = $row["price"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $dynamicList .= '<table width="100%" border="0" cellspacing="0" cellpadding="6"> <tr> <td width="17%" valign="top"><a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77" height="102" border="1" /></a></td> <td width="83%" valign="top">' . $product_name . '<br /> $' . $price . '<br /> <a href="product.php?id=' . $id . '">View Product Details</a></td> </tr> </table>'; } } else { $dynamicList = "We have no products listed in our store yet"; } mysql_close(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Store Home Page</title> <link rel="stylesheet" href="style/style.css" type="text/css" media="screen" /> </head> <body> <div align="center" id="mainWrapper"> <?php include_once("template_header.php");?> <div id="pageContent"> <table width="100%" border="0" cellspacing="0" cellpadding="10"> <tr> <td width="32%" valign="top"><h3>xxx</h3> <p>xxx</p></td> <td width="35%" valign="top"><h3>Latest Designer Fashions</h3> <p><?php echo $dynamicList; ?><br /> </p> <p><br /> </p></td> <td width="33%" valign="top"><h3>xxx</h3> <p>xxx</p></td> </tr> </table> </div> <?php include_once("template_footer.php");?> </div> </body> </html> If someone can help me I'd be so grateful! I want to know can we do text formatting to a result coming from echo if so then kindly guide how? I need make error lower then 3 and higher then 15 how should i add higher then 15? Code: [Select] if (strlen($searchTerms) < 3) { $error[] = "Add more then 3 symbols and less then 15!"; }else { $searchTermDB = mysql_real_escape_string($searchTerms); // prevent sql injection. } First of all, the field that holds prefgender does not say "Not added yet". Yet when I do this, it doesn't echo the info: Code: [Select] $prefgender = $req_user_info['prefgender']; if(!$prefgender == "Not added yet"){ ?> <tr> <td>Preferred gender:</td> <td><? echo $req_user_info['prefgender'] ?></td> </tr> <? } Any ideas? Is there a simple way of sorting data like this? $string = " 50|1|0|15|1|1~ 13|2|0|15|1|1~ 50|3|0|15|1|0~ 19|1|2|10|0|0~ 19|2|2|10|0|0~ 22|4|2|10|0|0~ 22|3|2|10|0|0~ 19|5|2|10|0|0~ 1|6|2|10|1|0~ 19|6|1|10|1|1 "; I treat this data as a string, and create an array out of it as follows: $individuals = explode("~", $string); Then I can divide up each individual as follows: foreach ($individuals as $individual) { $individual = explode("|", $individual); } How can I write something that sorts this data by $individual[0], $individual[1], and $individual[2], respectively and in that order?? After sorting I should get the following: $string = " 1|2|10|0|0~ 13|2|0|15|1|1~ 19|2|1|10|0|0~ 19|5|2|10|0|0~ 19|6|1|10|1|0~| 19|6|2|10|1|1~ 22|3|2|10|0|0~ 22|4|2|10|0|0~ 50|1|0|15|1|1~ 50|3|0|15|1|0 "; Help? I have no idea how to write such a function. Thank you guys. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=319098.0 <?php query_posts('showposts=10'); ?> <!-- The 10 most recent post, the first one not included --> <h2>Other Recent Articles</h2> <ul> <?php while (have_posts()) : the_post(); ?> <li><span class="title"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></span> <span class="meta"></span></li> <?php endwhile; ?> </ul> <br /> <p class="link"><a href="<?php echo get_option('home'); ?>/archives" title="View Archives">View Archives</a></p> The the first line in the code will display the last 10 posts from all categories. this one: <?php query_posts('showposts=10'); ?> But I want to display the last 10 posts from all categories EXCEPT for the newest post in category 12. so the formula should look something like this... <?php query_posts('showposts=10 BUT DO NOT INCLUDE THE NEWEST POST FROM CAT 12 '); ?> I'm not sure how to do this, can anyone help? Hello guys, I don't really know php but I am always been able to copy/paste it and move stuff around on my wordpress website until now. This last challenge is beyond my skills though (I am sure it will be trivial for you). So I have this code snippet to show a video duration <?php global $post; $video = cbc_get_video_data( $post ); if( $video ) { echo $video->get_human_duration(); } ?> And I have this code to show a post title if ($show_title) { $title_content .= apply_filters( 'uncode_before_body_title', '' ); $title_content .= '<div class="post-title-wrapper"><h1 class="post-title">' . get_the_title() . '</h1>'; $title_content .= uncode_post_info() . '</div>'; $title_content .= apply_filters( 'uncode_after_body_title', '' ); } I want to show the video duration right before the post title and in line with it, so inside the h1 tag. How to do that? Thanks for any help!
I've actually ported the query below from something else I've done that works. Not sure what I'm missing.
Here are the errors I'm getting: Quote
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home2/csi/public_html/resources/preview1920/functions.php on line 9
$query = "SELECT id FROM a_sectionals_bkb"; $results = mysqli_query($con,$query); //=> Line 9 echo mysqli_error($results); //=> Line 11 echo '<div class="sectional_select">'; echo '<form name="Sectionals">'; echo '<select name="sectional" size="3" onChange="go()">'; echo '<option value="NULL">Select Sectional</option>'; while($row = mysqli_fetch_assoc($results)) { echo '<option value="/season-preview/19-20/sectional1920/?sectional='. $row['id'] .'">Sectional '. $row['id'].'</option>'; } echo '</select>'; // End Sectional Select echo '</div>'; // End of Sectional Select Function
|