PHP - Dynamic Pages And Linking Issues
Hello,
I ran into new problem, I'm trying to figure this out for last two days, in total of 12 hours and you guys are my last hope. I've got 4 files that needs to be "connect" index.php <- contains one switch statement Here's part of it Code: [Select] $step = (isset($_GET['action'])) ? $step = $_GET['action'] : $step = "1"; switch($step) { //index case "1": include("admin/index.php"); break; second file is located in admin/index.php <- contains navigation links, pure html Here's part of it Code: [Select] <a href="?action=1">Home</a><br /> This is all working fine with no problems, which starts here I've got script for categories and subcategories which contains links and buttons Code: [Select] <input type="button" name="Button" value="Remove" onClick="location='?action=delete&id=<?=$c["id"]?>'"> [<a href="?action=delete&id=<?=$c["id"]?>">Remove</a> In first index.php located outside /admin/ folder, where switch statement is I have the following code case "delete": require("admin/categories.class.php"); $categories->delete($_GET["id"]); echo '<script>alert("Removed!"); location="admin/class_categories_test.php"; </script>'; break; and when I click on "Remove" I get the following error Quote Fatal error: Call to a member function delete() on a non-object in index.php As you may notice all functions are stored in admin/categories.class.php that's why I've require("admin/categories.class.php"); in switch statement. Regards Similar TutorialsHi everyone. I would like to do this: In page1.php, I need to make a few checkboxes, which when the user clicks "next" button, transfers the data (which checkboxes were clicked) to a database table. Then, when the user clicks a button "next", he is moved to another page, page2.php, from which he is automatically transferred to page3.php. At page3.php those values are gathered from the database, and the user has to click "next" button again, then those values are written into another table, in the same or another database. How can I do this? I've not much knowledge with neither SQL, neither PHP. I hope you will help me make this work, I'm making a little system for my HTML website. Thanks, if you do! Hey Im always trying to remove code and cut corners to reduce work in the long run, soIim wondering how I could link my menu bar from say a template to ALL my php pages for my site so I don't have to write/change links on every page when I need to. Thanks How can I go about making dynamic pages? eg. user types "phpfreaks.com/index.php?page=name" Hi, I hope someone can help. I currently have a page that includes the main page after login, however I am looking into changing this so that when a user logs in they get 3/4 linked images that, when clicked dynamically load/include the page based on the select i.e. user selects the image laptop, that has a hyperlink, it loads the laptop page. If anyone has any ideas or suggestion,i'd appreciate it. Hello, I'm having problems with creating send mail form, what it does it's just reload on "submit" click... I'm working on this for the last hour and still can't figure out what I'm missing. I don't get any error not even confirmation of successful or unsuccessful send... Here's the code <html> <body> <?php echo'<form enctype="multipart/form-data" method="post">'; echo'<form method="post" action="sendmail">'; echo'<input type = "text" value ="'.$email_to.'" name = "user_mail">'; echo '<input type="submit" name="Submit" value="Submit">'; echo '</form>'; ?> <?php elseif ($_GET['send']=='sendmail'):?> <?php $fileatt = "testfile.pdf"; // Path to the file $fileatt_type = "application/pdf"; // File Type $fileatt_name = "testfile.pdf"; // Filename that will be used for the file as the attachment $email_to = $user_mail; //send to $email_from = "dont@have.it"; // Who the email is from $email_subject = "Your attached file"; // The Subject of the email $email_message = "Thanks for visiting mysite.com! Here is your free file.<br>"; $email_message .= "Thanks for visiting.<br>"; // Message that the email has in it $email_to = $_POST['email']; // Who the email is to $headers = "From: ".$email_from; $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= "Here's your file .\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message .= "\n\n"; $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data .= "\n\n" . "--{$mime_boundary}--\n"; $ok = @mail($email_to, $email_subject, $email_message, $headers); if($ok) { echo "<font face=verdana size=2><center>Mail was sent.</center>"; } else { die("Sorry but the email could not be sent. Please go back and try again!"); } ?> <?php endif;?> </html> </body> I have created script that puts user information in MySQL database table called "Users" when they register. Now i want to create page to show all the accounts in that table and some custom fields they filled in as well. Like Name, Age, Sex. My table is 1Name 2Age 3Sex 4Email John 22 M john@gmail.com Kate 34 F kate@yahoo.com etc... I trying to show all users at once, so far i pulled info one by one successefully, and also queried that entire table trough array, but its creates huge list on one page i dont like this, i need to separate it to 10 accounts per page. How can i do that? I also like page 1, page2, page3 be linkable from homepage is there way to make them have static page like http://site.com/users.php?pages=2. Please advise. Hey everyone, I'm new to web programming so I thought I would join a active community to help me out. Anyhow, I'm making a game portal and I want the users games to have a url like so... games/username/gamename. From what I understand I could get this structure by simply using data from my login session(username) and using my upload form(gamename) and mkdir. Then I would need to have an index page inside every gamename folder? How would I add the index pages inside such folders. This way seems pretty inefficient to do considering I could pull the games dynamically in a single php file. Is there a way I can make my url look nice and still use one file to handle the embedding of the games, comments etc. Thanks Great conversation, wrong board. This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=357967.0 I got a question regarding a news website content that i want to make ! my question is how do i call my contents without using a lot of page? i explain let's say i got 10 news how do i put this 10 news in different pages without using 10 pages ? ex: you can see some links having a number like this http://bbc.uk/news/murder_case-12 then the next page got http://bbc.uk/news/finance-13 the title and the number id change but the page news doesnt change thanks for your answer. Folks, I need help (Php code ) to generate a Dynamic Text on a Base Image. What i want to do is, to make this Image as header on my Site and to make this Header Specific to a Site, i want to Add the Domain Name on the Lower Left of the Image. Got the Idea? Here is the Image link: Quote http://img27.imageshack.us/i/shoppingheader1.jpg/ PHP Variable that holds the Domain name is: $domain All i need the Dynamic PHP Codes that i can put on all my sites to generate this Text on Image (Header) Dynamically... May Anyone Help me with this Please? Cheers Natasha T. Hi all I need to combine these two scripts: Firstly, the following decides which out of the following list is selected based on its value in the mySQL table: <select name="pack_choice"> <option value="Meters / Pack"<?php echo (($result['pack_choice']=="Meters / Pack") ? ' selected="selected"':'') ?>>Meters / Pack (m2)</option> <option value="m3"<?php echo (($result['pack_choice']=="m3") ? ' selected="selected"':'') ?>>Meters / Pack (m3)</option> <option value="Quantity"<?php echo (($result['pack_choice']=="Quantity") ? ' selected="selected"':'') ?>>Quantity</option> </select> Although this works OK, I need it also to show dynamic values like this: select name="category"> <?php $listCategories=mysql_query("SELECT * FROM `product_categories` ORDER BY id ASC"); while($categoryReturned=mysql_fetch_array($listCategories)) { echo "<option value=\"".$categoryReturned['name']."\">".$categoryReturned['name']."</option>"; } ?> </select> I'm not sure if this is possible? Many thanks for your help. Pete I found this code which makes a BMI Calculator (Form) for me however when I click on submit it takes the user back to the index page ie. domain.com/index.php. How do I change it to go to, say, domain.com/calculator.php ? The code is below: <? /** * @package Module Body Mass Index Calculator for Joomla! 1.5 * @version $Id: mod_bodymassindexcalculator.php 599 2010-03-20 23:26:33Z you $ **/ defined( '_JEXEC' ) or die( 'Restricted access' ); $heightcm=$_POST["heightcm"]; $weightkg=$_POST["weightkg"]; if ($heightcm!="" && $weightkg!="") { $heightm = $heightcm / 100; $bmi=round($weightkg / ($heightm*$heightm),1); echo "Heigth, m: ".$heightm."<br />"; echo "Weigth, kg: ".$weightkg."<br />"; echo "Body Mass Index (BMI): ".$bmi."<br />"; echo "<strong>"; if ($bmi<16.5) {echo "Severely Underweight</strong><br />";} if ($bmi>=16.5 && $bmi<=18.4) {echo "Underweight</strong><br />";} if ($bmi>=18.5 && $bmi<=24.9) {echo "Normal</strong><br />";} if ($bmi>=25 && $bmi<=29.9) {echo "Overweight</strong><br />";} if ($bmi>=30 && $bmi<=34.9) {echo "Obese Class I</strong><br />";} if ($bmi>=35 && $bmi<=39.9) {echo "Obese Class II</strong><br />";} if ($bmi>=40) {echo "Obese Class III</strong><br />";} echo "<br />"; } $domain = $_SERVER['HTTP_HOST']; $path = $_SERVER['SCRIPT_NAME']; $queryString = $_SERVER['QUERY_STRING']; $url = "http://" . $domain . $path; $url3 = "http://" . $domain . $_SERVER['REQUEST_URI']; $mystring1="?"; $s1=strpos($url3,$mystring1); if($s1==0) {$url2=$url3;} if($s1!=0) {$url2=substr($url3,0,$s1);} $path = $url2; //1 foot = 0.3048 meters //1 inch = 2.54 centimeters //1 pound = 0.45359237 kilograms $n1=230; echo "<table style=\"width: 100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\"><tr><td valign=\"top\">"; //echo "<h3>BMI Calculator</h3>"; echo "<form action=\"".$path."\" method=\"post\" >"; echo "<strong>Height</strong><br />"; echo "<select name=\"heightcm\" >"; for ($i=30; $i<=$n1; $i++){ echo "<option value=\"$i\">".$i." cm / ".floor($i / 30.48)." ft ".round(($i-(floor($i / 30.48)*30.48)) / 2.54, 1)." in </option>";} echo "</select>"; echo "<br />"; echo "<strong>Weight</strong><br />"; echo "<select name=\"weightkg\" >"; for ($i=30; $i<=$n1; $i++){ echo "<option value=\"$i\">".$i." kg / ".round($i / 0.45359237,2)." pounds </option>";} echo "</select>"; echo "<br />"; //echo "<input name=\"searchterm\" type=text size=\"27\" class=\"ns1\">"; echo "<br />"; echo "<input type=\"submit\" value=\"Calculate\" name=\"B1\">"; echo "</form><br />"; //DON'T REMOVE THIS LINK - DO NOT VIOLATE GNU/GPL LICENSE!!! echo "<a href=\"http://nutritioncaloriecounter.com\">Nutrition Calorie Counter</a>"; //DON'T REMOVE THIS LINK - DO NOT VIOLATE GNU/GPL LICENSE!!! echo "</td></tr></table>"; ?> This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=326928.0 is there a way in php to link from the root dir ? like in html you just use the '/' at the start for the link " <a herf="/link.php" ></a> " but i noticed this does not work when using php like include or require. so is there anywey to tell a link to start from root dir? without using the ../../link.php I have this code : <img class= "image_frame1" src="images/groupproductimages/<?php echo $offer['cimage'];?>" /> It pulls pics I need the pics to link to urls using this code <a href="index.php?option=com_grouppurchase&view=todaysdeal&id=<?php echo $offer['cid'];?>"> I know I am missing something stupid <?php $con = database_connect(); $sql = "SELECT * FROM anime1, episode1 WHERE animeid='$animeid'"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { $title = $row['title']; $ep = $row['ep']; } ?> keep giving me back error Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\wamp\www\studying\take 2\addin12.php on line 45 Hi I got three tables (employers , company , and Jobs) Employer table holds info about employer. Company hold info about the company and jobs table holds info about jobs. I was just wandering what would be a good way to link these tables in the database ? Here is the coding for each table. Employer Table Code: [Select] CREATE TABLE IF NOT EXISTS `employers` ( `id` int(11) NOT NULL, `username` varchar(50) NOT NULL, `password` varchar(50) NOT NULL, `email` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; Jobs Table Code: [Select] CREATE TABLE IF NOT EXISTS `Jobs` ( `id` int(11) NOT NULL, `JobTitle` varchar(200) default NULL, `Company` varchar(200) default NULL, `Salary` varchar(30) default NULL, `Description` varchar(2000) default NULL, `CompanyURL` varchar(200) default NULL, `PhoneNumber` varchar(30) default NULL, `Requirements` varchar(2000) default NULL, `JobCategory` varchar(100) default NULL, `JobType` varchar(100) default NULL, `Apply_To` varchar(1000) NOT NULL, `Email` varchar(200) NOT NULL, `modified_at` datetime NOT NULL, `PostedOnDate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `Address` varchar(250) NOT NULL, `State` varchar(200) NOT NULL, `City` varchar(200) NOT NULL, `Country` varchar(100) NOT NULL, `Zipcode` varchar(100) NOT NULL, `JobID` varchar(100) NOT NULL, `WorkExperience` varchar(2000) NOT NULL, `EducationRequirement` varchar(2000) NOT NULL, `WebsitePostedFrom` varchar(200) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; Company Table Code: [Select] CREATE TABLE IF NOT EXISTS `Company` ( `id` int(11) unsigned NOT NULL auto_increment, `CompanyName` varchar(100) NOT NULL, `Address` varchar(100) NOT NULL, `Logo` varchar(100) NOT NULL, `PhoneNumber` varchar(25) NOT NULL, `ContactPerson` varchar(25) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=321572.0 I have been trying to figure out how this is done? One php file and all that changes is the name of the brand and the logo. This has to be clickable from a menu and also if a user changes the brand name it changes to the appropriate name and logo. Any ideas as to how this is done? If you can guide me in the right direction or give me an example of how this is done would be greatly appreciated. Thanks. http://www.drivermanager.com/en/download-confirmation.php?brand=compaq&logo= Hi All, I googled this and there is endless results. I went through a lot of them but couldn't get this working properly. How do I link from within my web site root to files outside the root? It works for me using relative links i.e. ../../phpfiles/includes but that is going to get messy and I can't get a way of doing absolute links to work. If someone could lay that out so a newbie can get it clearly I would really appreciate it! Also - I understand why I should put all of my php files outside the web root but is this a guaranteed way to secure these files other than someone hacking my ftp access? I've looked at a few site hierarchy examples - Am I right that the only pages within the web site root should be template pages with calls to required files (outside the root), session checks, and content includes and all other includes that have php executable code should be outside the root? I really appreciate the advice and insight. Thank you! |