PHP - Dynamically Create User Pages
Hi, i coded a very simple forum "website" with registration, login, and a place where everyone posts comments. I wanted to make some sort of profile page for each user so they would each have their own URL too (e.i. test/barney or test/simpsons). each of these pages would have different content, depending on what barney or simpsons puts on that page.
i've been looking everywhere trying to find documentation but i don't think i know how to search it correctly. I checked a lot of mod_rewrite documentation but i don't understand if i'm suppose to call a php function to create a profile page or something. Any guidance would be greatly appreciated Thanks! Similar TutorialsI have not created any code for this as I dont know where to start, or what its even called. I am on about trying to create a page dynamically depending on the id which is selected. Parts of the URL will change depending on what id is selected for example: 'http://www.facebook.com/home.php?sk=h. i am wanting to create a video website, where when the thumbnail of a video is clicked, a new page is loaded with that more details of the video and the video itself, and im guessing the url would change to identify the id of the video. I cannot create a page for every video by hand, as i will have many videos and this is not very efficient. I am just after the name of this technique or a pointer to a tutorial for how to achieve this. Thanks, Matlab Hii,
I created a view with few selected data from table. I provided link to title to have redirection on editing page. I am passing variables to dynamic editing page. In editing page, I created a form which is filled automatically using id. Now on submission of updated form I redirected it to another php page for back-end processing. But now I am not getting data of inputs from editing page. POST and GET both are not working. I don't understand why is it not passing values.
Login ► View Data ► Select Data To Update ► Update Is not working here
Edited by Parth_Innovator, 05 December 2014 - 12:57 PM. We recently migrated over to a new AMP platform that I built from source and now we can't dynamically generate images. It seems like GD is properly included into PHP (although I didn't know then I could do it using dynamic modules): My PHP configure is as follows: ================================================== './configure' '--prefix=/export/appl/pkgs/php/v5.3.9' '--with-apxs2=/export/appl/pkgs/httpd/latest/bin/apxs' '--with-mysql=/export/appl/pkgs/mysql/latest' '--with-mysqli=/export/appl/pkgs/mysql/latest/bin/mysql_config' '--with-gd=/export/appl/pkgs/libgd/latest' '--with-pear' '--with-png-dir=/export/appl/pkgs/libpng/latest' '--with-jpeg-dir=/export/appl/pkgs/jpeg/latest' '--with-curl=/export/appl/pkgs/curl/latest' '--with-freetype-dir=/export/appl/pkgs/freetype/latest' '--with-mhash=/export/appl/pkgs/mhash/latest' '--with-mcrypt=/export/appl/pkgs/libmcrypt/latest' '--enable-pcntl' '--enable-soap' '--enable-mbstring' '--with-zlib-dir=/export/appl/zlib/v1.2.5' '--with-ldap' ================================================== The GD section in phpinfo is as follows: ================================================== GD Support enabled GD Version 2.0 FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.4.6 GIF Read Support enabled GIF Create Support enabled JPEG Support enabled libJPEG Version unknown PNG Support enabled libPNG Version 1.5.5 WBMP Support enabled Directive Local Value Master Value gd.jpeg_ignore_warning 0 0 ================================================== I get broken image icons in IE and Chrome, and I get an "image cannot be displayed" msg in FF. I'd appreciate someone clubbing me with a cluestick. - Joe I have a slideshow that I am having to modify for my needs. The data file uses an array and i need this to be dynamic. I need to loop through all images in a directory and create the array. I have the directory being stored in a variable already. Now i just need to loop though all images in that directory to create the array like you see in the below code. You can also see the directory variable at the top. Can someone give me a hand with this please? Code: [Select] <?php echo $slideimagefolder; //http://localhost:82/images/groupphotos/1/1/ $slides = array( // --- Start slide list --- // slide elements array( "slidelink" => "http://www.frontpageslideshow.net", "title" => "Frontpage Slideshow 1.7", "category" => "About Frontpage Slideshow", "tagline" => "Image taken from the movie \"Shoot 'em up\"", "text" => "\"Frontpage SlideShow\" is the most eye-catching way to display your featured articles, stories or even products in your php based website or CMS, like Time.com, Joost.com or Yahoo! Movies do. \"Frontpage SlideShow\" creates an uber-cool slideshow with text snippets laying on top of images. These \"slides\" are being rotated one after the other with a nice fade effect. The slideshow features navigation and play/pause buttons, so the visitor has complete control over the slideshow's \"playback\"! And best of all, Frontpage Slideshow can be skinned!", "slideimage" => "ao4.jpg" ), // slide elements array( "slidelink" => "http://www.frontpageslideshow.net", "title" => "Use Frontpage Slideshow on any PHP based site!", "category" => "About Frontpage Slideshow", "tagline" => "Image taken from the movie \"The Kingdom\"", "text" => "JoomlaWorks has developed this modification of Frontpage Slideshow to work on every website that supports PHP as a minimum requirement. We call this modification the \"Static PHP\" version of Frontpage Slideshow. It's ideal for use on non-Joomla!/Mambo websites, like for example your corporate PHP based website or your Wordpress blog or Drupal website! You can obviously use this version on any CMS that is based on PHP!", "slideimage" => "the_kingdom_20070820114258369.jpg" ), // slide elements array( "slidelink" => "http://www.frontpageslideshow.net/content/view/14/37/", "title" => "FPSS is Search Engine Friendly!", "category" => "About Frontpage Slideshow", "tagline" => "Image taken from the movie \"Invaders\"", "text" => "Unlike Flash based slideshows, Frontpage Slideshow uses unobtrusive javascript and some CSS wizardry only. The content of the slides is laid out as html code, which means it can be \"read\" by search engines. The proper usage (and order) of h1, h2, p (and more) tags will make sure Google (or any other search engine) regularly \"scans\" your latest/featured items.", "slideimage" => "TVD_TR_02183_2.jpg" ), // slide elements (***TIP***: copy this data block and paste it below itself to add more slides) array( "slidelink" => "http://www.joomlaworks.gr", "title" => "About JoomlaWorks", "category" => "", "tagline" => "Image taken from the movie \"Transformers\"", "text" => "JoomlaWorks is a team of professional web designers and developers dedicated to delivering high-quality extensions and templates for Joomla! (the most popular open source Content Management System (CMS) worldwide) and Mambo (award winning CMS). JoomlaWorks has established a solid reputation in the Joomla! & Mambo communities, having developed some of the most popular and innovative free & commercial extensions & templates, since 2006.", "slideimage" => "2007_transformers_014_1.jpg" ), // --- End slide list --- ); ?> Friends, I have a PHP script that populates a calendar based on an array as follows: $days = array(2=>array('javascript:showWhatsOnText(2);','linked-day'), 3=>array('javascript:showWhatsOnText(3);','linked-day'), 4=>array('javascript:showWhatsOnText(4);','linked-day')); echo generate_calendar(2011, 4, $days, 1, '#'); where, for instance, the 2, 3 4 are the days of the month, By extracting a series values from a MySQL database how would I generate this array dynamically. E.g I have startday, startmonth, name and text fields in the database and would need to loop through them all to create the array. I tried playing around with something like this without any luck: $queryCat1 = "SELECT * FROM $dbCalendarEvents ORDER BY id ASC"; // WHERE visible = '1' $result1 = mysql_query($queryCat1) or die (mysql_error()); $num1 = mysql_num_rows($result1); $i=0; $daysArray = array(); while ($i < $num1) { $startday=mysql_result($result1,$i,"startday"); $startmonth=mysql_result($result1,$i,"startmonth"); $name=mysql_result($result1,$i,"name"); $name=mysql_result($result1,$i,"name"); $copy=mysql_result($result1,$i,"copy"); $daysArray[$i] = $startday=>array('/weblog/archive/2004/Jan/02','linked-day'); $i++; } Your help is appreciated. Hi guys i have to create text field & enter data and store in the data base. here im able to create text field but couldn't insert the data. so could anyone please check this code for me. <body> <form method="POST" action="cell.php"> Enter the number of question <input type="text" name="question"> <input type="submit"> <?php $value=$_POST['question']; for($i=0;$i<$value;$i++) { echo "Question NO:"; echo '<input type="text" name="qno">'."\t"; echo "Enter Marks:"; echo '<input type="text" name="marks">'."\t"; echo "<br>"; } ?> </form> <form name="form1" method="post" action="cellresult.php"> <label> <input type="submit" name="Submit" value="Submit"> </label> </form> </body> cellresult.php <body> <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("test", $con); $sql="INSERT INTO cell (QNO,MARKS) VALUES ('$_POST[qno]','$_POST[marks]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> </body> Hi, I want to create a .html file dynamically on the server. Below is the code for that but i was not able to create the file. I have given all the read, write and execute permission on the folder. $filerand = rand(); $fileName = "test.html"; $filepath = $_SERVER['DOCUMENT_ROOT'] . "\\testfolder\\" . $fileName . ".html"; echo $filepath; $bodytxt = "Welcome to my webpage"; $ourFileHandle = fopen($filepath, 'w') or die("can't open file"); fwrite($ourFileHandle, $bodytxt); fclose($ourFileHandle); Thanks in advance Hi, This problem has been driving me crazy all day. I am relatively new to PHP. I basically am trying to populate a database with data from site users. I am using session variables to store their data temporarily as they navigate through the sign up process. A user will input how many 'categories' they wish to populate on page 1. Page 2 will then ask them to specify the details of each category. Eg Category 1: Title, Description, Amount. Category 2: Title, etc. So far I have been able to do this, I now want to store what they have input in session variables. My thoughts were to take the number of categories they have sepcified and create that number of arrays using a loop. Each array will store the details on each category. My code is as follows: Code: [Select] $count=$_POST['count']; //Get how many categories were added //Create an array for each category for ( $counter = 0; $counter <= $count; $counter++){ ${'Categoryarr'.$counter} = array(); }; for ( $counter = 0; $counter <= $count; $counter++){ $Categoryarr[$counter][1]=$_POST['amount_'.$count]; $Categoryarr[$counter][2]=$_POST['desc_'.$count]; $Categoryarr[$counter][3]=$_POST['title_'.$count]; }; When I output the code, I seems to have created the specified number of arrays, but has populated all of them with the same data from the last category. Does anyone know where I am going wrong? Thanks, Bernard How to create a pdf dynamically and that pdf should sent as a email attachment.
Hi, I have a table row that has a dropdown and two textboxes in it. I would like to use a button that allows me to add another row beneath the existing row. It cannot be added to the bottom of the table as there is further content beneath. The content of the dropdown comes from a database query. The dropdown on the new row should have the selection in the first row greyed out. I expect this will need to be a js function but i dont really know where to start with it being dynamic content. This is the table as it stands if this provides clarity of my intentions - picture below echo "<form method='post' id='staffOrderForm'>"; $stmt->close(); echo "<table id='staffOrderTable' class='table table-striped table-bordered mt-3 text-center'>"; foreach($daterange as $date){ echo" <tr> <th class='table-dark' colspan='3'>".$date->format("l - jS F Y")."</th> </tr> <tr> <th class='' colspan='3'>Management </th> </tr> <tr> <th class='col-4'>Name</th> <th class='col-4'>Start Time</th> <th class='col-4'>End Time</th> </tr> <tr> <td> <select class='custom-select managerSelect'>"; $managerRoleId = 1; $stmt = $conn->prepare(" SELECT user_firstname, user_lastname, user_id FROM ssm_user WHERE user_role_id = ? "); $stmt->bind_param("i", $managerRoleId); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($ufn, $uln, $uid); while($stmt->fetch()){echo "<option>".$ufn." ".$uln."</option>";}; echo"</select> </td> <td><input class='form-control' type='' name=''></td> <td><input class='form-control' type='' name=''></td> </tr> <tr> <th colspan='3'>Chefs</th> <tr/> <tr> <th class='col-4'>Name</th> <th class='col-4'>Start Time</th> <th class='col-4'>End Time</th> </tr> <tr> <td> <select class='custom-select chefSelect'>"; $chefRoleId = 2; $stmt = $conn->prepare(" SELECT user_firstname, user_lastname, user_id FROM ssm_user WHERE user_role_id = ? "); $stmt->bind_param("i", $chefRoleId); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($ufn, $uln, $uid); while($stmt->fetch()){echo "<option>".$ufn." ".$uln."</option>";}; echo"</select> </td> <td><input class='form-control' type='' name=''></td> <td><input class='form-control' type='' name=''></td> </tr>"; } echo "</table></form>"; I appreciate that i will likely have to add a button with an onclick but from there i am pretty lost. As always i appreciate the help provided. hey i am using a MySql database and i need to create a dynamic HTML table with one of its columns as checkboxes.so i have to create multiple checkboxes.but these checkbox values are to be stored in a mysql table and then later retrieved when form reloads.and depending on previous state when form was submitted, the newly created checkboxes have to be checked in the same manner.so how do i store multiple checkbox values in my table and also how do i retrieve them? please help. Hi. I have a rating site where users fill in a name of what they are rating, comments about it and a rating and submit it to my database. I then have another page which shows all of these entries but only the name and overall rating using php. What I want is for users to click on the name and it take them to a separate page which displays all the comments and ratings for that item. As users can add items to rate I cant set up a page for each manually so was wondering how to do it dynamically. Everything i throw into google leads me in the wrong direction though. If someone could point me to a good tutorial or give me an idea about what to search id be very grateful. Cheers. Hi, I don't know why it outputs" You are now registered BUT the user name and password don't show up in the database! I want to encrypt the passwords so maybe that is problem, I don't know, please read scripts below. here is register.php: ============== Code: [Select] <html> <head></head> <body> <form method="post" action="" > <p>Create a username <input type="text" name="newUsername"/> </p> <p>Create a password <input type="password" name= "newPassword" /> </p> <p> <input type="submit" value="Make account now" name="makeAccountSubmit" /> </p> </form> <?php if(array_key_exists("makeAccountSubmit",$_POST) && !empty($_POST["newUsername"]) && !empty($_POST["newPassword"]) ) { //IF username doesn't exist, then store new user login info to db dummydpevx mysql_connect("localhost","root"); mysql_select_db("someDB"); $newUserName=$_POST["newUsername"]; $newPassword=crypt($_POST["newPassword"]); $usernameQuery=mysql_query("SELECT userName FROM users WHERE userName='$newUserName'"); if(mysql_num_rows($usernameQuery)==0) { $makeNewAccountQuery=mysql_query("INSERT INTO users userName,userPassword VALUES('$newUserName','$newPassword')"); print "You are now registered, <a href='login.php'>proceed to login</a>"; } if(mysql_num_rows($usernameQuery)==1) print "Username taken. Please make another one. <br />"; } here is login.php: ============ Code: [Select] <html> <head></head> <body> <form method="post" action=""> <label>Username:</label> <input type="text" name="username" /> <br /> <label>Password:</label> <input type="password" name="password" /> <p> <input type="submit" value="Login" name="Login" /> <input type="reset" value="Reset" name="Reset" /> </p> </form> <?php if(array_key_exists("Login",$_POST) && !empty($_POST["username"]) && !empty($_POST["password"])) { $attemptedUsername=$_POST["username"]; $attemptedPassword=$_POST["password"]; mysql_connect("localhost","root"); mysql_select_db("someDB"); $getLoginInfoQuery=mysql_query("SELECT userName,userPassword FROM users WHERE userName=$attemptedUsername AND userPassword=$attemptedPassword"); $getLoginInfo=mysql_fetch_assoc($getLoginInfoQuery); $getUsername=$getLoginInfo["userName"]; $getPassword=crypt($getLoginInfo["userPassword"]); if(crypt($attemptedPassword,$getPassword)==$getPassword) { session_start();//NB: Start session BEFORE doing any session stuff! $_SESSION["isAuthenticated"]="userAuthenticated"; header("Location: xmlShredderIndex.php"); exit; } else print "Please register!"; } Also, if any has time, please see my other post, it is straightforward instructions to see if you get same error as me, thanks. http://www.phpfreaks.com/forums/index.php?topic=347639.msg1640652#msg1640652 Any help much appreciated! 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 Hello friends, I am new to PHP and have developed a website... i am stuck at one place. I want to know if the user changes the url in the adress bar and goes to another webpage.. Can we detect that? This is very important for my website because I calsulate the duration of login based on whether user goes to another page or logs out. 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. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=346715.0 example:
pulling a 5x5 array of data from a database
time differences:
components (unbuilt):13400101661682
elements (built):13817119598389
How I'm stealing the elements from the PHP code:
ob_start();
...
ob_end_clean();
Hi guys, in my database i have the table called users, where i have 5 fields (id, username, email, password, user_level) - for the user_level field i have 2 options administrator and editor.
What i want to do is that when the user who is logged in have administrator in the user_level field to see all the pages from backend, and the user who have in the user_level field editor to see only some of the pages from the backend such as newsletter, or messages.
I hope you understand what i'm asking if not fell free to ask me if you need more specific details.
I tried to make a php page called access.php wher i put the following code, but not working
<?php session_start(); $sql = $mysqli->query("SELECT user_level FROM imobiliare_users WHERE id=$id"); $user_level = $mysqli->query($sql); echo $user_level; if ($user_level !="administrator") { echo "You are not the proper user type to view this page"; die(); } ?>Hope you can help me. Thx in advance for help. I can't find out whats the problem here, would appreciate some input in how to think building my "if".
The problem is that I don't seem to catch if an email exists, nor if user exists and neither can I create a new user :/.
Appreciate your help alot!
<?php // Start the session in case of errors to display within the page of user creation session_start(); $err_msg = array(); $errflag = false; // Check if the submit button was pressed if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_POST['submit'] === 'Skapa') { // Crypt password $options = ['cost' => 10]; $username = strip_tags($_POST['uname']); $password = strip_tags(password_hash($_POST['pword'], PASSWORD_DEFAULT, $options)); $email = strip_tags($_POST['uname'], '@'); // Check so all the fields are filled if ($_POST['uname'] == '' || $_POST['pword'] == '' || $_POST['pwordcheck'] == '') { $err_msg[] = 'Please enter all fields<br>'; $errflag = true; } // See if passwords and confirm matches if ($_POST['pword'] !== $_POST['pwordcheck']) { $err_msg[] = 'Passwords doesn\'t match!<br>'; $errflag = true; } // Check password length, atleast 8 characters if (strlen($_POST['pword']) < 7) { $err_msg[] = 'Password must be atleast 8 characters long'; $errflag = true; } // Check if email exists include_once('../includes/db.inc.php'); $db = new PDO(DB_INFO, DB_USER, DB_PASS); $sql = "SELECT COUNT(*) AS count FROM movies WHERE email = :emailadress"; $stmt = $db->prepare($sql); $stmt->bindParam(':emailadress', $email); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); if ($row > 0) { $err_msg[] = 'Email already taken!'; $errflag = true; $db = NULL; } // Check if user exists include_once('../includes/db.inc.php'); $db = new PDO(DB_INFO, DB_USER, DB_PASS); $sql = "SELECT uname FROM users WHERE uname = :username"; $stmt = $db->prepare($sql); $stmt->bindParam(':username', $username); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); if ($row > 0) { $err_msg[] = 'User already exists'; $errflag = true; $db = NULL; } if ($errflag = false) { // Everything passed, create the user! include_once('../includes/db.inc.php'); $db = new PDO(DB_INFO, DB_USER, DB_PASS); $sql = "INSERT INTO users (uname, pword, email) VALUES (:username, :password, :emailadress)"; $stmt = $db->prepare($sql); $stmt->bindParam(':username', $username); $stmt->bindParam(':password', $password); $stmt->bindParam(':emailadress'); $stmt->execute(); $_SESSION['uname'] = $username; header('Location: ../template/header.php'); exit; } // If any error, send the user back and display messages if ($errflag == true) { $_SESSION['err_msg'] = $err_msg; session_write_close(); header('Location: ../user/create.php'); exit; } } else { $_SESSION['err_msg'] = $err_msg; session_write_close(); header('Location: ../user/create.php'); exit; } ?> |