-
BIG MYSQL PROBLEM Please Help! :O
Personally i would use W3schools to start off! You will learn the fundimentals of Php & mysql alot quicker! Also download a good text editor like Jedit to practise with! Good luck.
-
MySql move
You Could also try mysql administrator! Could you not just do a databse dump from your previous server & import it into your new 1...
-
Formmail
I have a form that works pefect! You will have to change the databse connection fields & add your email were necessery! Here is the form: stick all this code in your web page! Make sure you have html & body headers: <table border="0" cellspacing="10" cellpadding="2" bgcolor="white"> <form action="mail.php" method="post"> <tr> <td class="style2">Name:</td> <td><input type="text" name="Name" /></td> </tr> <br /> <tr> <td class="style2">Email address:</td> <td><input type="text" name="Email" /></td> </tr> <br /> <tr> <td class="style2">Message:</td> <td><textarea name="Message" cols="30" rows="10"></textarea></td> </tr> <br /> <tr> <td></td> <td><input type="submit" /></td> </tr> </form> </table> Here is hte php code that will process and send the email! One thing to remember is that it wont work on localhost! Upload it to your server & make sure you fill in all fields mentioned above database connection fields and input your email address: <?php $SendFrom = "Form Feedback <Put your email address here jimme>"; $SendTo = "Put your email address here jimme"; $SubjectLine = "Feedback Submission"; $ThanksURL = "jimme put a url here to direct the user to once email sent"; //confirmation page // Build Message Body from Web Form Input foreach ($_POST as $Field=>$Value) $MsgBody .= "$Field: $Value\n"; $MsgBody .= "\n" . @gethostbyaddr($_SERVER["REMOTE_ADDR"]) . "\n" . $_SERVER["HTTP_USER_AGENT"]; $MsgBody = htmlspecialchars($MsgBody, ENT_NOQUOTES); //make safe // Send E-Mail and Direct Browser to Confirmation Page mail($SendTo, $SubjectLine, $MsgBody, "From: $SendFrom"); header("Location: $ThanksURL"); ?> Hop this helps dude Andy
-
Help it's broken!
Hi Rachael! If you are at the point were you are implementing applications into your website you must havea general interest in web design!! Why dont you follow the steps below: Create a fully functional webserver manually or just use XAMMP ! Use dreamweaver to create pages to handle your photo galeries & downloads! Use PHP\msql to handle your photo uploads & managment & possible accounts to your website!! Al most of these applications like plogger are is a simple content backend managment system that within a couple of months of learning you could create your own!! Try W3schools website & practise php & you will see what i mean.... If you dont fancy learning pure code you could use dreamweavers inbuilt functionality-but this feature is limited!! I hope this helps... Happy coding Andy
-
Login & be directed to profile
Hello i recently created a control panel with Search\Edit\View profile features using php & mysql!! I decided to add a login user feature to my website using dreamweavers login wizard. The idea is the user logs in & is directed to a page were all there account information is displayed from the database.. Basically just imagane someone called joe blogs registeres on my site & he logs in, when he logs in i need his data to display in the page specified once login succesfull!!! I have managed to get the login to work, and the logged in user is directed to the profile page-(were i would like there database information to be display)!!! All i am loking for is a solution or a code fix!!! Below i will post my login code & profile page: <?php require_once('Connections/dbelite.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=$_POST['password']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "Your_account.php"; $MM_redirectLoginFailed = "Login_failed.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_dbelite, $dbelite); $LoginRS__query=sprintf("SELECT workerusername, workerpassword FROM tbl_worker WHERE workerusername=%s AND workerpassword=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $dbelite) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> <!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>Untitled Document</title> <link href="style/screen.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .style1 {color: #0099FF} --> </style> </head> <body> <p>Login Failed! Please try again. Or click <a href="Index.php" class="style1">here</a> to go back to the main page.</p> <table width="230" height="150" border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top"><form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>"> <table width="230" height="113" border="3" cellpadding="0" cellspacing="0"> <tr> <td valign="top"><table width="245" height="107" border="0" cellpadding="0" cellspacing="0" id="tbl_insert"> <tr> <td width="75"><strong>User name:</strong></td> <td width="150"><input type="text" name="username" id="username" /></td> </tr> <tr> <td><strong>Password:</strong></td> <td><input type="text" name="password" id="password" /></td> </tr> <tr> <td> </td> <td><div align="center"> <input type="submit" name="button" id="button" value="Submit" /> </div></td> </tr> </table></td> </tr> </table> </form> </td> </tr> </table> <p> </p> </body> </html> Here is my profile page: <?php require_once('Connections/dbelite.php'); ?><?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "Login_failed.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) $MM_referrer .= "?" . $QUERY_STRING; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_rsWorker = "-1"; if (isset($_GET['id'])) { $colname_rsWorker = $_GET['id']; } mysql_select_db($database_dbelite, $dbelite); $query_rsWorker = sprintf("SELECT tbl_worker.workername, tbl_worker.workersurname, tbl_worker.workergender, tbl_worker.workerage, tbl_worker.workertown, tbl_worker.workeraddress, tbl_worker.workeremail, tbl_worker.workerphone, tbl_worker.workerprogram, tbl_worker.workerabout, tbl_worker.workerjoinreasons, tbl_worker.workerfurtherinfo, tbl_worker.workerphoto FROM tbl_worker WHERE workerid = %s", GetSQLValueString($colname_rsWorker, "int")); $rsWorker = mysql_query($query_rsWorker, $dbelite) or die(mysql_error()); $row_rsWorker = mysql_fetch_assoc($rsWorker); $totalRows_rsWorker = mysql_num_rows($rsWorker); ?> <!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>Welcome To Your Personal Account</title> <link href="style/screen.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .style1 { color: #FFFFFF; font-weight: bold; font-size: 12pt; } .style3 {color: #0099FF} .style4 { color: #006600; font-weight: bold; } .style5 { color: #FFFFFF; font-weight: bold; } --> </style> <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script> </head> <body> <table width="636" height="681" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="636" height="84" valign="top"><div align="center"> <table width="641" height="26" border="0" cellpadding="0" cellspacing="0"> <tr> <td bgcolor="#99FF33"><div align="center" class="style1">Elite Mail Services | Homeworkers Profile </div></td> </tr> </table> <p>You are now <span class="style3">logged</span> in as: <?php echo $row_rsWorker['workername']; ?> <?php echo $row_rsWorker['workersurname']; ?></p> </div> <p> </p></td> </tr> <tr> <td valign="top"><table width="640" height="587" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="444" valign="top"><div align="center"> <table width="406" height="569" border="0" cellpadding="0" cellspacing="0" id="tbl_insert"> <tr> <td width="152" height="45"><div align="left"><span class="style4">Name:</span></div></td> <td width="148"><?php echo $row_rsWorker['workername']; ?></td> </tr> <tr> <td height="48"><div align="left"><span class="style4">Surname:</span></div></td> <td><?php echo $row_rsWorker['workersurname']; ?></td> </tr> <tr> <td height="41"><div align="left"><span class="style4">Gender:</span></div></td> <td><?php echo $row_rsWorker['workergender']; ?></td> </tr> <tr> <td height="46"><div align="left"><span class="style4">Age:</span></div></td> <td><?php echo $row_rsWorker['workerage']; ?></td> </tr> <tr> <td height="43"><div align="left"><span class="style4">City:</span></div></td> <td><?php echo $row_rsWorker['workertown']; ?></td> </tr> <tr> <td height="44"><div align="left"><span class="style4">I am a member of:</span></div></td> <td><?php echo $row_rsWorker['workerprogram']; ?></td> </tr> <tr> <td height="91"><div align="left"><span class="style4">About me:</span></div></td> <td><?php echo $row_rsWorker['workerabout']; ?></td> </tr> <tr> <td height="101"><div align="left"><span class="style4">Why i joined:</span></div></td> <td><?php echo $row_rsWorker['workerjoinreasons']; ?></td> </tr> <tr> <td><div align="left"><span class="style4">Extra information:</span></div></td> <td><?php echo $row_rsWorker['workerfurtherinfo']; ?></td> </tr> </table> </div></td> <td width="196" valign="top"><table width="197" height="397" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="194"><img src="uploads/<?php echo $row_rsWorker['workerphoto']; ?> " width="199" height="200" style:"width:300px; max-width:300px" alt="<?php echo $row_rsWorker['workername']; ?> <?php echo $row_rsWorker['workersurname']; ?>" /></td> </tr> <tr> <td valign="top"><table width="198" height="169" border="0" cellpadding="0" cellspacing="0"> <tr> <td><div align="center"> <table width="185" height="157" border="2" cellpadding="0" cellspacing="0" bordercolor="#99FF33"> <tr> <td height="22" bgcolor="#99FF33"><div align="center"><span class="style5">User control panel</span></div></td> </tr> <tr> <td valign="top"><table width="185" height="135" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="141"><div align="right">Edit Profile:</div></td> <td width="44"><div align="center"> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','38','height','22','src','button3','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','#FFFFFF','movie','button3' ); //end AC code </script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="38" height="22"> <param name="movie" value="button3.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#FFFFFF" /> <embed src="button3.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="38" height="22" bgcolor="#FFFFFF"></embed> </object> </noscript></div></td> </tr> <tr> <td><div align="right">View Account Balance:</div></td> <td><div align="center"> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','38','height','22','src','button4','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','#FFFFFF','movie','button4' ); //end AC code </script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="38" height="22"> <param name="movie" value="button4.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#FFFFFF" /> <embed src="button4.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="38" height="22" bgcolor="#FFFFFF"></embed> </object> </noscript></div></td> </tr> <tr> <td><div align="right">Contact Support:</div></td> <td><div align="center"> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','38','height','22','src','button5','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','#FFFFFF','movie','button5' ); //end AC code </script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="38" height="22"> <param name="movie" value="button5.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#FFFFFF" /> <embed src="button5.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="38" height="22" bgcolor="#FFFFFF"></embed> </object> </noscript></div></td> </tr> <tr> <td><div align="right">Delete Account:</div></td> <td><div align="center"> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','38','height','22','src','button6','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','#FFFFFF','movie','button6' ); //end AC code </script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="38" height="22"> <param name="movie" value="button6.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#FFFFFF" /> <embed src="button6.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="38" height="22" bgcolor="#FFFFFF"></embed> </object> </noscript></div></td> </tr> </table></td> </tr> </table> </div></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> </table> <table width="636" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td bgcolor="#99FF33"><div align="center"></div></td> </tr> </table> <p align="center"> </p> <p> </p> </body> </html> <?php mysql_free_result($rsWorker); ?> I have previosly got this working by adding a extra session id, to the login code but is seems to duplicate the login user function.... i no its a big post but the code needed to fix the problem is small Cheers
-
Session id
Nice one buddy!!! Thanks very much!!! i will start busting my brains with this until i have managed it.. Good day & take care
-
Session id
Thanks very much, this is proof to me that this forum is much more helpfull & polite than "Web Forumz"!!! Just one question, do i put this code in the login page or in my profile page??? Second of all could you bunch together what the final code should look like please mate, so i have one bunch of code to together, this way i no i will have the code in the right order.... Thanks very much for your help mate.. Cheers
-
Session id
Hello all!! Could some please take a look at my php profile page. Here is my problem: On my index page i have a members login witch connects to my database to validate username, if the username exists they are diverted to the profile page, all this works apart from this: When the user is diverted to the profile page i would like there profile data from the databse to display in the profile page. I no that i need to use session id or a cookie, but i simply dont no how to do it... I will post the entire code of my profile page. Please dont feel (Oh god am not going near that becuase the amount of code posted) becuase its just the cookie or session code that needs adding... Am new to PHp but learning very quickly... I have attached my php profile page to this post... Like i say it prbebly just a couple of lines of code, my main problem is not knowing were to put it, so it works properly... Cheers. Please help!!! Accounts.php
-
PHP - Logic behing my problem
Why not create a php web page with following features: Mysql database Userlogin & session data loading the logged in users account page, A submit form inputting the users chosen day to arrive at your courses, You could also you paypal buttons to pay for your course, this would also confirm the booking i guess... Your database could be your diary..
-
Image upload from form
Sorry gibson i should have explained better mate, i can already write the code needed to upload images into a file & the name into a database its just i have used an array for me signup form and am unsure of the code that i would use to upload the images so i still am able to use my array (Get me drift) i carnt figure out the php array code to upload the image into the file & the name into the database, any suggestions anyone???
-
Image upload from form
Hello, I have a small form and data mysql databse, the form is PHp coded so the information from the form fields get inserted into the database once the submitt button is pressed, all is going well except the to file browsers in the form are supposed to upload the images to my images folder in my sites directory & the name os the images are supposed to be input into the database coloumns: image_one & image_two! Basically am just unsure about the php code needed to upload the images, could some one please demonstrate how this is done by altering my code??? I would be very gratfull!! I recieved help today on my search engine & totaly got the drift on how its done, so am hoping to solve this problem of mine to!! Me code works its just the images part that confusing me!! Cheers, Thanks everone, Andy Here is me code: <?php require_once('Connections/dbtest.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO members (first_name, last_name, image_one, image_two) VALUES (%s, %s, %s, %s)", GetSQLValueString($_POST['first_name'], "text"), GetSQLValueString($_POST['last_name'], "text"), GetSQLValueString($_POST['image_one'], "text"), GetSQLValueString($_POST['image_two'], "text")); mysql_select_db($database_dbtest, $dbtest); $Result1 = mysql_query($insertSQL, $dbtest) or die(mysql_error()); } $con = mysql_connect("localhost","root","longstand1"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("dbtest", $con); if (!empty($_POST['button'])) { $needStrip = get_magic_quotes_gpc(); $fields = array(); $fields['select'] = array('type' => 's', 'required' => true, 'column' => 'first_name' ); $fields['select2'] = array('type' => 's', 'required' => true, 'column' => 'last_name' ); $fields['select2'] = array('type' => 's', 'required' => true, 'column' => 'image_one' ); $fields['select2'] = array('type' => 's', 'required' => true, 'column' => 'image_two' ); $errors = array(); $cols = ''; $vals = ''; foreach ($fields as $field => $dets) { $field = trim($field); if ($dets['required'] && empty($_POST[$field])) { $errors[] = $field . ' is a required field!'; continue; } if ($dets['type'] == 'n' && !is_numeric($_POST[$field])) { $errors[] = $field . ' should be a number!'; continue; } if (empty($_POST['field']) || count($errors)) continue; $_POST[$field] = $needStrip ? stripslashes($_POST[$field]) : $_POST[$field]; $_POST[$field] = mysql_real_escape_string($_POST[$field]); if (!empty($cols)) { $cols .= ', '; $vals .= ', '; } $cols .= $dets['column']; $vals .= $dets['type'] == 'n' && is_numeric($_POST[$field]) ? $_POST[$field] : "'{$_POST[$field]}'"; } if (!count($errors) && !empty($cols) && !empty($vals)) { $query = "INSERT INTO members($cols) VALUES($vals)"; mysql_select_db($database_dbtest, $dbtest); $result = mysql_query($query) or die(mysql_error()); $message = "Yay, you have been inserted as " . mysql_insert_id(); // The insert ID } else { $message = '<strong>The following errors are screwing up my feung shui man!</strong> <ol>'; foreach ($errors as $err) $message .= '<li>' . $err . '</li>'; $message .= '</ol>'; } } ?><!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>Untitled Document</title> </head> <body> <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1" id="form1"> <p>Input Name: <input type="text" name="first_name" id="first_name" /> </p> <p>Input Surname: <input type="text" name="last_name" id="last_name" /> </p> <p>Upload Photo: <input type="file" name="image_one" id="image_one" /> </p> <p>Upload Photo 2: <input type="file" name="image_two" id="image_two" /> </p> <p> <input type="submit" name="button" id="button" value="Submit" /> </p> <input type="hidden" name="MM_insert" value="form1" /> </form> </body> </html> Here is my sql databse: CREATE DATABASE IF NOT EXISTS dbtest; USE dbtest; CREATE TABLE `members` (`members_id` INT( 3 ) NOT NULL AUTO_INCREMENT, `first_name` VARCHAR(30) NOT NULL , `last_name` VARCHAR(30) NOT NULL , `image_one` VARCHAR(10) NOT NULL , `image_two` VARCHAR(10) NOT NULL , UNIQUE ( `members_id` ) );
-
Php Search Engine Example
Thanks Mate cheers for the help!! Take Care Andy,
-
Php Search Engine Example
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>search</title> <style type="text/css"> <!-- #nav { margin: 1px; padding: 0; list-style: none; width: 200px; float:right; background-color: #CCFFCC } --> </style> </head> <body> <?php $link = mysql_connect("localhost","root","longstand1"); mysql_select_db("dbsignup", $link) or die("Unable to select database"); # $selectSql1 = "SELECT * FROM customer WHERE gender = '".mysql_real_escape_string($_POST['gender'])."' AND area = '".mysql_real_escape_string($_POST['area'])."'"; $result = mysql_query($selectSql1, $link) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { ?> <?php echo '<pre>'; print_r($row); echo '</pre>'; } mysql_close($link); ?> <form action="Search_engine.php" method="post"> <table width="323" height="250" border="5" cellpadding="0" cellspacing="0"> <tr> <td width="155"><div align="right">Gender:</div></td> <td width="154"><label> <select name="gender" id="gender"> <option>Male</option> <option>Female</option> </select> </label></td> </tr> <tr> <td><div align="right">Age:</div></td> <td><label> <select name="age" id="age"> <option>18</option> <option>19</option> <option>20</option> <option>21</option> <option>22</option> <option>23</option> <option>24</option> <option>25</option> <option>26</option> </select> </label></td> </tr> <tr> <td><div align="right">Height</div></td> <td><label> <select name="height_one" id="height_one"> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>8</option> </select> To <select name="height_two" id="height_two"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>8</option> <option>9</option> <option>10</option> <option>11</option> </select> </label></td> </tr> <tr> <td><div align="right">Hair Colour:</div></td> <td><label> <select name="hair_colour" id="hair_colour"> <option>Black</option> <option>Brown</option> <option>Blonde</option> <option>Red</option> <option>Auburn</option> <option>Other</option> </select> </label></td> </tr> <tr> <td><div align="right">Area:</div></td> <td><label> <select name="area" id="area"> <option>England-Bath Avon</option> <option>England-Bedforshire</option> <option>England-Berkshire</option> </select> </label></td> </tr> <tr> <td><div align="right">Work Interested:</div></td> <td><label> <select name="desired_work" id="desired_work"> <option>Look-A-Likes</option> <option>Models & Glamour</option> <option>Actors & TV Extras</option> <option>Singers & Vocalists</option> <option>Theatre & Musicals</option> <option>Producers&Aegents</option> </select> </label></td> </tr> </table> <input type="submit" /> </form> </body> </html> Thanks you very much for replying sir! My site is Php based, and i need the search engine to search the fields in my mysql database, i am still learning Php so i get confused real quick, would you be kind enough to send me a example?? I can send you my database & search engine that i put together but it displays there results in an array (Really looks unproffessional), i need the search engine to only display 4 ofthe resulst out of the database, (First name/Age/Area/Tallent. Really stuck on this one to the point of stress.. Could you help me fine tune it?? Here is my form & Php code: Here is my sql databse: CREATE DATABASE IF NOT EXISTS dbsignup; USE dbsignup; CREATE TABLE `customer` (`customer_id` INT( 3 ) NOT NULL AUTO_INCREMENT, `first_name` VARCHAR(30) NOT NULL , `last_name` VARCHAR(30) NOT NULL , `address` VARCHAR(70) NOT NULL , `city` VARCHAR(40) NOT NULL , `area` VARCHAR(50) NOT NULL , `email` VARCHAR(70) NOT NULL , `phone` VARCHAR(20) NOT NULL , `user_name` VARCHAR(30) NOT NULL , `password` VARCHAR(30) NOT NULL , `work_location` VARCHAR(60) NOT NULL , `agency_name` VARCHAR(70) NOT NULL , `agency_number` VARCHAR(30) NOT NULL , `skills` VARCHAR(500) NOT NULL , `about_me` VARCHAR(500) NOT NULL , `myspace_address` VARCHAR(50) NOT NULL , `hotmail_yahoo_address` VARCHAR(50) NOT NULL , `gender` VARCHAR(10) NOT NULL , `age` VARCHAR(3) NOT NULL , `height_one` VARCHAR(20) NOT NULL , `height_two` VARCHAR(20) NOT NULL , `build` VARCHAR(20) NOT NULL , `eye_colour` VARCHAR(20) NOT NULL , `hair_colour` VARCHAR(30) NOT NULL , `desired_work` VARCHAR(100) NOT NULL , `image_one` VARCHAR(10) NOT NULL , `image_two` VARCHAR(10) NOT NULL , `image_three` VARCHAR(10) NOT NULL , `image_four` VARCHAR(10) NOT NULL , UNIQUE ( `customer_id` ) ); Please help, as you can se am a tryer am just lost at the moment??
-
Php Search Engine Example
Hello i have recently been learning Php, i have successfully created signup/login/logout/email submit forms using PHP but i am having real trouble trying to create or find a working example of a search engine that uses php! I have tried google but only appear to find rubbish, either has bit n bobs of code & no form, or has the form & no instructions that explain lamens terms! I love larning but i need examples to see how things are done & hopefullt say (Oh yer i no ow it works now) get me drift? Anyone please please please got a example of a search engine with a form so i can see how its done?? dont matter how small just enough so i can adapt from there and learn peace by peace. Cheers, Take Care All, Andy.