PHP - Help With Basic Php Website That Works With Mysql Database
Hey there
I have to make a php driven website that uses the CRUD operations to modify a simple MySQL database
anyone willing to help me with this in detail?
PM me if possible please
thanks
Similar TutorialsHi there, I am having a bit of trouble understanding what I am doing, basically all I want at the moment is to be able to make a very basic introductory guide for myself on my own Database class implementation. I know there are some around on the web but I thought for my own education I would create one of my own, just to see if I can fully understand what it is I am doing. It won't at this present moment involve anything more than a standard class, with 3 properties: protected $_connect This will be the basis for mysql_connect stuff. protected $_query As you probably would have guessed the basis for the mysql_query strings this application will do. protected $_error Then finally any errors that occur will go through this function, right thats the properties done for now (please feel free to add any should you feel I should need them though, why I am asking for your help ). Right here is my code, it is all on the same file, say class.db.php or something simple, just to see how I can get this working firstly, then I will segregate (or more split the new Db class into its own file), then have my actual form generation going from another class file and then do a real implement of the whole thing. Again this is only for my own education, nothing else! Here is my class file for the database: class Db { protected $_connect; // dont allow credentials in here yet! protected $_query; // holds the query info? protected $_error; // raises an error message when needed! public function __construct($host,$username,$password) { $this->_connect = mysql_connect($host,$username,$password); } } $newDatabase = new Db("localhost","dbuser","password"); echo "<pre>"; print_r($newDatabase); echo "</pre>"; What it's bringing up though is along the lines of this: Quote Db Object ( [_connect:protected] => Resource id #2 [_query:protected] => [_error:protected] => ) Is there any obvious error I am doing to not allowing the properties to fill up or something? I cant seem to get this working, again any helps appreciated, Jeremy. I'm a beginner to PHP and am stuck as to how I can fetch data from a MYSQL database and output that information in html to the website.
Currently I get the information from the database using normal php:
$result = mysql_query("SELECT * FROM truffleProducts");Then I assign each field from the database to a php variable in a while loop: while ($row = mysql_fetch_array($result)) { $id = $row{'id'}; $name = $row{'name'}; $price = $row{'Price_per_kg'}; $season = $row{'Season'}; $country = $row{'Country'}; $image = $row{'image'}; $review = $row{'review'}; }Then I just print each variable in a table using simple html and php. My problem is that it only outputs the latest element or row from my database. I want to output the database within a HTML template so that it is professional and tidy, but i cant figure out how to do that. Any help? Edited by louiscb, 22 October 2014 - 07:58 AM. Hey guys, im new around here, and i have just recently started teaching myself PHP, by looks of this site i seem very experienced but im eager to learn I seem to get an error with this code. The point of this code is to look into my database and pull out all entries with the first name _____ (whatever the user inputs) Error: Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\xampp\htdocs\searchans.php on line 12 Code: Filename:search.php Code: [Select] <html> <form action='searchans.php' method='POST'> First Name: <input type='text' name='firstname'><br> <input type='submit' value='Search'> </form> </html>Code: Filename:searchans.php Code: [Select] <?php $firstname = $_POST['firstname']; $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } $query = mysql_query("SELECT * FROM Persons WHERE FirstName='$firstname'"); while($row = mysql_fetch_array($result)) { echo $row['FirstName'] . " " . $row['LastName'] . " " . $row['Age']; echo "<br />"; } ?> Hi. Can someone show me the proper way to do a feedback form (like a "Contact US" form). I have read about SQL injections and would like to know I am protecting against it. And the proper way to store the submitted data in a database for a client's records. I have a basic form I use, but I am unable to store the data properly. Any help or a code idea would be appreciated. Thanks much. I got a script that receive info from paypal "ipn" when someone is making a payment from my shop. I wanted to edit the script a bit as i am adding a bonus system to it. After i added Quote // Bonus system vars if ($item_name == '301') { $point == "1"; } elseif ($item_name == '302') { $point == "2"; } elseif ($item_name == '303') { $point == "3"; } elseif { $point == "0"; } And Quote $bonus1 = "update Bonus set points=points+'$points' where username='$username'"; mysql_query("$bonus1"); $bonus2 = "update Bonus set points_total=points_total+'$points' where username='$username'"; mysql_query("$bonus2"); $bonus3 = "update Bonus set $item_name=$item_name+1 where username='$username'"; mysql_query("$bonus3"); The script wont work. But it does when i remove those things. I think my problem is at the if,elseif i just dont know why. Do i need to put it in some kind of while loop? Here is the full php code Code: [Select] mysql_connect('xxxxx', 'xxxx', 'xxxxxx'); $notify_email = "xxxx@xxxx"; // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } // post back to PayPal system to validate $header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30); // assign posted variables to local variables $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; $buyer_firstname = $_POST['first_name']; $buyer_lastname = $_POST['last_name']; $timestamp = $_POST['payment_date']; $address_street = $_POST['address_street']; $address_city = $_POST['address_city']; $address_state = $_POST['address_state']; $address_zip = $_POST['address_zip']; $username = $_POST['custom']; // Bonus system vars if ($item_name == '301') { $point == "1"; } elseif ($item_name == '302') { $point == "2"; } elseif ($item_name == '303') { $point == "3"; } elseif { $point == "0"; } mysql_select_db('redlite'); if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { if ($payment_status == 'Completed') { $sql = "insert into tblMail values ('','$txn_id','$payer_email',' $item_name','$timestamp','','','','$payment_amount $payment_currency','$buyer_firstname $buyer_lastname','$address_street $address_city , $address_state $address_zip','','','$username')"; mysql_query("$sql"); $bonus1 = "update Bonus set points=points+'$points' where username='$username'"; mysql_query("$bonus1"); $bonus2 = "update Bonus set points_total=points_total+'$points' where username='$username'"; mysql_query("$bonus2"); $bonus3 = "update Bonus set $item_name=$item_name+1 where username='$username'"; mysql_query("$bonus3"); $ttlpay_sql = "update totalpay set total=total+'$payment_amount' where id='1'"; mysql_query("$ttlpay_sql"); mail($notify_email, "CLVerified", "$res\n $req"); } else { mail($notify_email, "CLVerified - But not completed". "$res\n $req"); } } else if (strcmp ($res, "INVALID") == 0) { mail($notify_email, "CLINVALID IPN", "$res\n $req"); } } fclose ($fp); } ?> Hey y'all, I'm trying to write a PHP script for a login function. There are three elements, two text fields (username and password) and a button which calls the script. Segment from index.php file: <form action = "login.php" method = "POST"> Admin Login: <br> Username: <input type = "text" name = "usernameField"/><br> <!-- Password field--> Password: <input type = "password" name = "passwordField"/><br> <!-- Username field --> <input type = "button" value = "Login" name = "submitButton"/> <!-- Login button --> </form> Segment from login.php file: <?php $connect = mysql_connect("localhost", "root", "root"); if(!$connect){//If user can't connect to database die('Could not connect: ' . mysql_error()); //Throw an error } mysql_select_db("colin_db", $connect); //Get given username and password from username field and password field $givenUsername = $_POST["usernameField"]; $givenPassword = $_POST["passwordField"]; $myQuery = "SELECT * FROM ADMINS WHERE USERNAME = '$givenUsername' AND PASSWORD = '$givenPassword'"; $queryResult = mysql_query($myQuery); $numRows = mysql_num_rows($queryResult); if($numRows == 1){ //If the details are correct... //Reload the page and login echo "<script type = 'text/javascript'> window.location.reload() </script>"; } elseif($numRows == 0){ //Else if the details are not found //Display error accordingly echo "Details not correct!"; } mysql_close($connect); ?> The problem is, when I click the login button, it doesn't do anything. What am I missing? (The information in the database is correct) Thanks, Jake need help i startet to regenerate an old website but the one or other thing dont works so like that: Code: [Select] <? require("droplist.inc.php"); if (!isset($region)) $region = 0; $region_names = array("Laglamia", "Dekardi", "Dekadun", "Dekaran", "Shilon", "Searoost", "Paros", "GWH"); $region_monster_count = array(14, 12, 18, 19, 16, 26, 19, 8); ?> <head> <title>Dropliste</title> <meta http-equiv=content-type content="text/html; charset=windows-1252"> <meta http-equiv=imagetoolbar content=no> <link href="image/style.css" rel=stylesheet type="text/css"> </head> <body bgColor="#2d2d2d" link="#FFFFFF" vlink="#FFFFFF" alink="#FF9900"> <hr> <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <? for ($idx = 0; $idx < count($region_names); $idx++) { print("<a href=\"droplist.php?region=".$idx."\">"); if ($idx == $region) printf("<font color=\"#FF9900\">"); print($region_names[$idx]); if ($idx == $region) printf("</font>"); print("</a>"); if ($idx < count($region_names) - 1) print(" | "); print("\n"); } ?> </font></div> <hr> <table cellSpacing=0 cellPadding=1 width="95%" align=center border=0> <tr><td colSpan=3 height=1><br></td></tr> <tr><td bgColor=black colSpan=3 height=1></td></tr> <tr><td bgColor=silver colSpan=3 height=1></td></tr> <tr><td colSpan=3 height=1><br></td></tr> <? for ($idx = 0; $idx < $region_monster_count[$region]; $idx++) { printf(" <tr> <td width=135 valign=top align=center> <font face=\"Arial, Helvetica, sans-serif\" size=2> <img width=130 height=140 src=\"image/droplist/".$monsters[$region][$idx][0].".gif\" border=0> </font> </td> <td width=* valign=top> <font face=\"Arial, Helvetica, sans-serif\" size=2> <b>".$monsters[$region][$idx][1]."</b> <strong>[ Level ".$monsters[$region][$idx][2]." ]</strong> <br> <font color=#ffff00>Drops:</font><br><font face=\"Arial, Helvetica, sans-serif\" size=1>".$monsters[$region][$idx][3]."</font> <br> <font color=#ffff00>Random-Drops:</font><br><font face=\"Arial, Helvetica, sans-serif\" size=1>".$monsters[$region][$idx][4]."</font> </font> </td> </tr> <tr><td colSpan=3 height=1><br></td></tr> <tr><td bgColor=black colSpan=3 height=1></td></tr> <tr><td bgColor=silver colSpan=3 height=1></td></tr> <tr><td colSpan=3 height=1><br></td></tr> "); } ?> </table> <hr> <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <? for ($idx = 0; $idx < count($region_names); $idx++) { print("<a href=\"droplist.php?region=".$idx."\">"); if ($idx == $region) printf("<font color=\"#FF9900\">"); print($region_names[$idx]); if ($idx == $region) printf("</font>"); print("</a>"); if ($idx < count($region_names) - 1) print(" | "); print("\n"); } ?> </font></div> <hr> </body> </html> The content iss in another file the problem iss the links (you can see the page the http://psychadelics.co.de/droplist.php ) dont work if i click on it so the funktions must be have errors can annyone help me that if i click for example Dekardi that the list shows up for it? i hope annyone can help^^ Hi, I have just started using PHP again after a long break and am very rusty. I am having a few problems with some basic things: I have defined a function to connect to my MySQL database and it doesn't work. My $hostname, $username, $password variables are stored in a separate php file which I am including first and the standard mysql_connect function works ok, but I wanted to put it inside another user defined function called "condb" to make things quicker later. my function looks like this: function condb(){ mysql_connect($hostname, $username, $password) OR DIE ('Unable to connect to database! Please try again later.'); } and I am trying to run it like this: condb(); Unfortunately it is not working. Probably a basic error but any help appreciated. Thanks At the moment I am creating a search function for my website. The approach I have in mind is a pseudo-PHP database. To give an example: A HTML form will submit the results to a PHP file. HTML FORM - Colour: Black PHP RESULT PAGE - if ($_POST['color'] == 'Black') {readfile("./products/black/*.html");} HTML FORM - Price: <$50 PHP RESULT PAGE - if ($_POST['Price'] == '<$50') {readfile("./products/less50/*.html");} The problem here is if there is an item that is black and costs less than $50, then its going to be listed twice. There is probably some code I can write to ommit the listing of duplicate entries, but it is probably going to be messy, so I am wondering if its better to use a centralized MySQL database, rather than a pseudo-PHP database? I've never used MySQL and don't know much about it and this is my first real attempt at using PHP. I'm having trouble with a simple SELECT query. I just cannot figure out what the problem is... <?php //Include database connection details include 'login/config.php'; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } $qry="SELECT * FROM members"; $result = mysqli_query($link, $qry); echo "<table>"; while($row = mysqli_fetch_array($result, MYSQL_ASSOC)) { $getid = ($row['member_ID']); $firstname = ($row['firstname']); $lastname = ($row['lastname']); $email = ($row['email']); echo "<tr><td>$firstname</td><td>$email</td></tr>"; } echo "</table>"; ?> I know I have a connection to the DB, and I know that the query will return values as I have tested in in phpmyadmin. Can anyone see anything obvious I am missing? Thanks I've looked every where, probably googled every variation of my question I could come up with and I've tried all of the suggestions... I'm trying to connect to two different DBs in two different locations ($local and $remote) and only the second one works. Here is a sample of my code ("..." = hidden): //-------------Local DB Connection: $local = mysql_connect("localhost","root","..."); if (!$local) { die('Could not connect: ' . mysql_error()); } $sel1 = mysql_select_db("new", $local); //-------------Remote DB Connection: $remote = mysql_connect("...","...","...",true); if (!$remote) { die('Could not connect: ' . mysql_error()); } $table = "..."; //---------function selecting from local: function fncGrabNemsis($ele,$val){ mysql_select_db("new", $local); $result = mysql_query("SELECT * FROM new.tblvalues WHERE fldelement='$ele' AND fldcode='$val'",$local); $tmprow = mysql_fetch_array($result); return (isset($tmprow['fldvariable'])?$tmprow['fldvariable']:$val); } //----------Select run from Remote: mysql_select_db("ImdxTest", $remote); $result = mysql_query("SELECT * FROM ImdxTest.$table WHERE ClientID = ... AND IncidentNum = '$fldINCID'", $remote) or die(mysql_error()); $row = mysql_fetch_array($result); I've tried moving the mysql_select_db() function calls everywhere you can think of and just about everything else... What happens is, I get php errors saying that $local is not defined or that the mysql function that are trying to use the $local connection are expecting parameters to be resources!? I know for a fact that both connections work because individually they both work. Only the second connection ($remote) works... Thanks a lot for any suggestions! I have a really weird problem. I'm trying to run a mysql query that works fine in phpmyadmin but in php script is giving me an error. The query is: Code: [Select] (SELECT DISTINCT art.`TEMPLATE`,gal.`ARTICLE_ID`,art.`TITLE`,art.`DESCRIPTION`,MATCH(art.`TITLE`,art.`DESCRIPTION`,gal.`CONTENT`) AGAINST ('WORD*' IN BOOLEAN MODE) AS score FROM articles art,galeries gal WHERE gal.`ARTICLE_ID`=art.`ARTICLE_ID` AND MATCH(art.`TITLE`,art.`DESCRIPTION`,gal.`CONTENT`) AGAINST ('WORD* ' IN BOOLEAN MODE)) UNION (SELECT DISTINCT `TEMPLATE`,`ARTICLE_ID`,`TITLE`,`DESCRIPTION`,MATCH(`TITLE`,`DESCRIPTION`,`CONTENT`) AGAINST ('WORD* ' IN BOOLEAN MODE) AS score FROM articles WHERE (MATCH(`TITLE`,`DESCRIPTION`,`CONTENT`) AGAINST ('WORD* ' IN BOOLEAN MODE))) ORDER BY score DESC LIMIT 0,30 Snipset from php script code: function search($start_row,$ammount,$search_key,$pages){ $start_row = intval($start_row) * $ammount; $return_val = ""; $symbols = array('/','\\','\'','"',',','.','<','>','?',';',':','[',']','{','}','|','=','+','-','_',')','(','*','&','^','%','$','#','@','!','~','`' );//this will remove punctuation $pattern = "#[^(\w|α|β|γ|δ|ε|ζ|η|θ|ι|κ|λ|μ|ν|ξ|ο|π|ρ|σ|τ|υ|φ|χ|ψ|ω|Α|Β|Γ|Δ|Ε|Ζ|Η|Θ|Ι|Κ|Λ|Μ|Ν|Ξ|Ο|Π|Ρ|Σ|Τ|Υ|Φ|Χ|Ψ|Ω|ς|ά|έ|ό|ί|ύ|ώ|ή|ϊ|ϋ|ΐ|ΰ|Ά|Έ|Ό|Ί|Ύ|Ώ|Ή|Ϊ|Ϋ|\d|\'|\"|\.|\!|\?|;|,|\\|\/|\-|:|\&|@)]+#"; $search_key = greek_text::to_upper($search_key); $wc = strip_tags($search_key); $wc = preg_replace($pattern, " ", $wc); for ($i = 0; $i < sizeof($symbols); $i++) { $wc = str_replace($symbols[$i],' ',$wc); } $wc = str_replace("΄", " ", $wc); $wc = str_replace(chr(162), " ", $wc); if( !$keep_numbers ) { $wc = preg_replace('#(^|\s+)[\d\s]+(\s+|$)#',' ',$wc); $pattern = '#(^|\s+)([0-9]+[a-zA-ZαβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩςάέόίύώήϊϋΐΰΆΈΌΊΎΏΉΪΫ]+\s*)+(\s+|$)#'; preg_match($pattern,$wc,$aa); $wc = preg_replace($pattern, " ", $wc); } $wc = trim(preg_replace("/\s\s+/", " ", $wc)); $wc = explode(" ", $wc); $cleaned_keyword = array_filter($wc); $cleaned_keyword = greek_text::removeStopWordsFromArray($cleaned_keyword); $stemmed_keywords = greek_text::stemWordsArray($cleaned_keyword); $query = "(SELECT DISTINCT art.`TEMPLATE`,gal.`ARTICLE_ID`,art.`TITLE`,art.`DESCRIPTION`,MATCH(art.`TITLE`,art.`DESCRIPTION`,gal.`CONTENT`) AGAINST ('"; while(list($key,$val)=each($stemmed_keywords)){ if($val<>" " and strlen($val) > 1){ $query .= $val."*"; $search_keys .= $val."* "; } } $query .= "' IN BOOLEAN MODE) AS score FROM articles art,galeries gal WHERE gal.`ARTICLE_ID`=art.`ARTICLE_ID` AND MATCH(art.`TITLE`,art.`DESCRIPTION`,gal.`CONTENT`) AGAINST ('".$search_keys."' IN BOOLEAN MODE))"; $query .= " UNION (SELECT DISTINCT `TEMPLATE`,`ARTICLE_ID`,`TITLE`,`DESCRIPTION`,MATCH(`TITLE`,`DESCRIPTION`,`CONTENT`) AGAINST ('".$search_keys."' IN BOOLEAN MODE) AS score FROM articles WHERE (MATCH(`TITLE`,`DESCRIPTION`,`CONTENT`) AGAINST ('".$search_keys."' IN BOOLEAN MODE))) ORDER BY score DESC LIMIT ".intval($start_row).",".$ammount; $rs = $this->dbActions->execQuery($query); $this->dbActions->execQuery("INSERT INTO searches (`KEY`,`DATE`,`RESULTS`) VALUES ('".$search_key."',NOW(),".$pages.")"); $search_results = "<div id='results'>"; while($row = mysql_fetch_array($rs)){ $search_results.= "<div id='result'>"; $search_results.= "<div class='result_title'><h4><a href='article.php?articleId=".$row["ARTICLE_ID"]."'>".$row['TITLE']."</a></h4></div>"; $search_results.= "<div class='result_description'>".$row['DESCRIPTION']."</div>"; $search_results.= "</div>"; $search_results.= "<div class='result_seperator'></div>"; } $search_results .= "</div>"; $return_val = $search_results; return $return_val; } dbactions class: require 'includes/errors.php'; error_reporting(0); class DBActions{ var $dbCon; var $errorHandler; function DBActions(){ $this->dbCon = $this->dbCon(); $errorHandler = new errors(1); } private function dbCon(){ require 'conf/configuration.php'; $dbcon = mysql_connect($dbUrl,$dbUser,$dbPass); if(!$dbcon)trigger_error("Unable to connect to database $dbUrl for user $dbUser",E_USER_ERROR); mysql_select_db($dbName); mysql_query("SET NAMES 'UTF8'"); mysql_query('set character set utf8'); return $dbcon; } function dbClose(){ if($this->dbCon) mysql_close($this->dbCon); } function execQuery($query){ $result = mysql_query($query,$this->dbCon); $msg = "Unable to execute query ".$query; if(mysql_num_rows($result) > 0) return $result; else if($result == false) trigger_error($msg,E_USER_ERROR); else return $result; } function send_error_mail(){ $this->errorHandler->sendErrorEmail(); } } I've try everything but can't get this working.. Any healp whould be really appreciated. Thanks in advance.
Hi, this query runs fine when I run it from PHPMyAdmin: UPDATE `tran_term_taxonomy` SET `description` = (SELECT keyword from `good_keywords` ORDER BY RAND() LIMIT 1,1) WHERE `tran_term_taxonomy`.`taxonomy` = 'post_tag' AND `tran_term_taxonomy`.`description` = "" LIMIT 1 However, when I run the same query in a PHP file on my server, the page doesn't load at all. The message I get is: www.somesite.com is currently unable to handle this request. HTTP ERROR 500. This is my PHP code: <?php include("/database/connection/path/db_connect.php"); $result4 = mysqli_query($GLOBALS["___mysqli_ston"], "UPDATE `tran_term_taxonomy` SET `description` = (SELECT keyword from `good_keywords` ORDER BY RAND() LIMIT 1,1) WHERE `tran_term_taxonomy`.`taxonomy` = 'post_tag' AND `tran_term_taxonomy`.`description` = "" LIMIT 1"); echo $result4; ?> So how do I make this query work please? Thanks for your guidance. Hi! So I'm fairly new to PHP, and am currently making a website from scratch including as much PHP functionality as I can for learning purposes. As I have just finished making a blog function, I started to wonder. Is it normal to store every part of a website in a the database? The blog part of the website I just created has of course all the differet blog entries stored in a table in the db, but is it also normal practice to store about, contact etc. in tables too? Or should categories like these be created using brand new .php documents? I am in the progress of making a page controller and thought I should clearify things first, before I go any further. This question may seem stupid, but I don't know alot about what the normal practices of doing things like these in php are. Anyways, hope someone can help me out! I need help trying to figure out why my form won't write the database it is supposed to - i checked the connection to the database and it works and the user seems to have permission to edit database - the error I get is "Error: User not added to database." from "register.php". Can someone please look over my code and see if the problem is coming from somewhere within?
I created a connection file (connect.php)
<? session_start(); // Replace the variable values below // with your specific database information. $host = "localhost"; $user = "master"; $pass = "hidden"; $db = "user"; // This part sets up the connection to the // database (so you don't need to reopen the connection // again on the same page). $ms = mysql_pconnect($host, $user, $pass); if ( !$ms ) { echo "Error connecting to database.\n"; } // Then you need to make sure the database you want // is selected. mysql_select_db($db); ?>Then there is the php script (register.php): <?php session_start(); // connect.php is a file that contains your // database connection information. This // tutorial assumes a connection is made from // this existing file. require('connect.php'); // If the values are posted, insert them into the database. if (isset($_POST['email']) && isset($_POST['password'])){ $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $password = $_POST['password']; $query = "INSERT INTO `member` (firstname, lastname, email, password) VALUES ('$firstname', '$lastname', '$email' '$password')"; $result = mysql_query($query); if ( !mysql_insert_id() ) { die("Error: User not added to database."); } else { // Redirect to thank you page. Header("Location: surveylanding_no-sidebar.html"); } } ?>Here is the HTML form: <form name="htmlform" method="post" class="form" action="register.php"> <p class="firstname"> <input type="text" name="firstname" id="firstname" /> <label for="firstname">First Name</label> </p> <p class="lastname"> <input type="text" name="lastname" id="lastname" /> <label for="lastname">Last Name</label> </p> <p class="email"> <input type="email" name="email" id="email" /> <label for="email">Email</label> </p> <p class="Password"> <input type="password" name="password" id="password" /> <label for="password">Password</label> </p> <p class="submit"> <input type="submit" value="Register"/> </p> </form> Hi all, I've got a website for an event, each team have their details on a page which are recalled from a SQl database. But I'm wanting to create a password input box for each team, so when they enter the correct password they are taken to a page containing forms where they can edit the team details. Here is the page with the users details on where they anter the password: http://www.wharncliffenetwork.co.uk/wrc/entered/team.php?id=8 I'm not sure how to code it, Can an IF statement be used? Anyone got any pointers? I'f been unsuccessful in finding a tutorial or something similar. Hope that makes sense :S Cheers. HI. I am talking about this website. http://www.elfster.com/ Please browse this website. Can any one tell me how database structure / queries will work? (i know PHP / MYSQL) Can any one guide me a little bit. I would really appreciate it, Thanks Waiting for reply. Dear all friends, I don't know this forum already have kindly of this question or not. I'm coding my won php and mysql. but I have no idea with two wanted idea as below: 1. when I post on my website. It will automaticall post in my page in facebook 2. when friend in facebook comment on that item it will also show that comment on my facebook page and also my website too. I'm please to getting your idea event from general idea and technical idea. thanks for your answer. All of your answer and idea very important to me. Best Regards Steve. |