ianhaney
Members-
Posts
330 -
Joined
-
Last visited
-
Days Won
1
Everything posted by ianhaney
-
I can post the coding below, one sec and will post the coding below is the coding the checks the login form <?php session_start(); $_SESSION['user'] = $_POST['user']; //connect to db //insert validation of credentials here //then, store user_id in session session_start(); ob_start(); $host=""; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $tbl_name=""; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $userid = mysql_query("SELECT userid FROM users WHERE username='$_POST[username]'"); $_SESSION['userid']=$userid; // Define $myusername and $mypassword $username=$_POST['username']; $password=$_POST['password']; // To protect MySQL injection (more detail about MySQL injection) $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("username"); session_register("password"); header("location:loginsuccess.html"); } else { echo "Wrong Username or Password"; } ob_end_flush(); ?> below is the coding that checks the registration form <?php session_start(); //=============Configuring Server and Database======= $host = ''; $user = ''; $password = ''; //=============Data Base Information================= $database = ''; $conn = mysql_connect($host,$user,$password) or die('Server Information is not Correct'); //Establish Connection with Server mysql_select_db($database,$conn) or die('Database Information is not correct'); //===============End Server Configuration============ //=============Starting Registration Script========== $email = $_POST['email']; $username = $_POST['txtUser']; $password = $_POST['txtPassword']; //=============To Encrypt Password=================== $password = md5($salt.$password); //============New Variable of Password is Now with an Encrypted Value======== if(isset($_POST['btnRegister'])) //===When I will Set the Button to 1 or Press Button to register { $query = "insert into users(email,username,password)values('$email','$username','$password')"; $res = mysql_query($query); header('location:registersuccess.html'); } ?> <?php $to = "$email"; $subject = "Registration Details"; $message = "Email: $email \n Username: $username \n Password: $password"; $from = "ianhaney@irhwebsites.co.uk"; $headers = "From: $from"; mail($to,$subject,$message,$headers); echo "Mail Sent."; ?>
-
I am not 100% sure on how to fix it, hence need the help I have tried using sessions but am not 100% sure on php so am prob doing it wrong somewhere
-
Hi Got couple of problems I need urgent help with I need a urgent login and registration script that works, the current one I am using is no good for the following reasons I register and stores the info in the database but when I go to login with the details I have just registered, it says the password is wrong so I check it and copy the password from the database into the login form and works, trouble is the password in the database is not the one I created, its generating a different password in the database, think its using all that md5 stuff to hide the password so I need a login and registration form that actually logs in with the password I create in the registration form My second problem is I need to display the username of the user logged in on a order confirmation page Please help me, been trying for hours and the brain is going now and eyes are hurting from trying to figure it out Thank you in advance Kind regards Ian
-
Hello I have got a feedback form on my website that when a customer writes a testimonial it gets automatically added to my testimonials.php page but have noticed that if a customers writes the word can't for example, the testimonial is not displayed on the website and is not being added to the database table either due to the character ' in the word betwen the n and t and have found out it is to do with the following line I think $query = "insert into testimonials(name,testimonial)values('$name','$testimonial')"; How would I change that line or insert a bit of coding so that characters like ' and others are displayed when words that have them characters in are added to the database table Kind regards Ian
-
Hi I have created a php forgotten password page but when I receive the forgotten password email, I only get the email address in the email and not the username and password, its not collecting the username and password data for some reason The php coding is below in the forgottenpassword.php <?php if($go == "1") { $connect = mysql_connect("host","username","password"); if (!$connect) { die("MySQL could not connect!"); }[/background][/size][/font] [font=Verdana, Geneva, sans-serif][size=3][background=rgb(225, 239, 247)]$DB = mysql_select_db('databasename');[/background][/size][/font] [font=Verdana, Geneva, sans-serif][size=3][background=rgb(225, 239, 247)]if(!$DB) { die("My SQL could not select Database!"); } }[/background][/size][/font] [font=Verdana, Geneva, sans-serif][size=3][background=rgb(225, 239, 247)]$Username = $_POST['username']; $Email = $_POST['email']; $Email1 = "@"; $Email_Check = strpos($Email,$Email1); $Password = $_POST['password']; $message_field = $_POST['username, password']; $message = "$Email, $Username, $Password, $message_field"; ?> <?php //These are the variables for the email [/background][/size][/font] [font=Verdana, Geneva, sans-serif][size=3][background=rgb(225, 239, 247)]$sendto = $_POST['email']; // this is the email address collected from the form $ccto = "ianhaney@irhwebsites.co.uk"; //you can cc it to yourself $subject = "Your Registration Details"; // Subject $message = "Email Address: " . $Email . "\n\n" . "Username: " . $Username . "\n\n" . "Password: " . $Password . "\n\n" . "$message_field"; $header = "From: ianhaney@irhwebsites.co.uk\r\n"; $header .= "Reply-to: ianhaney@irhwebsites.co.uk\r\n"; // This is the function to send the email mail($sendto, $subject, $message, $header, $message_field); echo "Your password has been sent to ". $Email ."."; ?> Below is what the email comes out like Email Address: ianhaney@irhwebsites.co.uk Username: Password: my html form is below <form action="forgotpassword.php" method="post"> E-mail: <input type="text" name="email" size="24" border="0"> <br> <input type="hidden" name="username" border="0"> <input type="hidden" name="password" border="0"> <input type="hidden" name="go" value="1" border="0"> <input type="submit" name="submitButtonName" value="Submit" border="0"> </form> Please help, been stuck on this for a while now Kind regards Ian
-
I have a mobile version of my website and on this link http://www.irhtoys.co.uk/mobile-shipping-address.php the update button is not working It works ok on my normal website but just not the mobile version for some reason I have tried copying the code from the checkout-shipping-address.php from the normal site that processes the new address part but still does the same thing and not update a new address The code is below from the mobile-shipping-address.php - if anyone could take a quick look at it and point me in the right direction, I would really appreciate it or inform me how to fix it, been trying to solve this for 2 days now and im getting headache with it to be honest <?php /* mobile-shipping-address.php, http://www.css-oscommerce.com >modified from shipping_address.php OSC to CSS v2 2010, http://www.css-oscommerce.com >modified from $Id: shipping_address.php 1739 2007-12-20 00:52:16Z hpdl $v2.2RC2a osCommerce, http://www.oscommerce.com Released under the GNU General Public License */ require('includes/mobile_application_top.php'); // if the customer is not logged on, redirect them to the login page if (!tep_session_is_registered('customer_id')) { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } // if there is nothing in the customers cart, redirect them to the shopping cart page if ($cart->count_contents() < 1) { tep_redirect(tep_href_link(FILENAME_SHOPPING_CART)); } require(DIR_WS_CLASSES . 'order.php'); $order = new order; if ($order->content_type == 'virtual') { if (!tep_session_is_registered('shipping')) tep_session_register('shipping'); $shipping = false; if (!tep_session_is_registered('sendto')) tep_session_register('sendto'); $sendto = false; tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); } $error = false; $process = false; // if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'submit')) { if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'submit') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) { // process a new shipping address if (tep_not_null($HTTP_POST_VARS['firstname']) && tep_not_null($HTTP_POST_VARS['lastname']) && tep_not_null($HTTP_POST_VARS['street_address'])) { $process = true; if (ACCOUNT_GENDER == 'true') $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']); if (ACCOUNT_COMPANY == 'true') $company = tep_db_prepare_input($HTTP_POST_VARS['company']); $firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']); $lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']); $street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']); if (ACCOUNT_SUBURB == 'true') $suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']); $city = tep_db_prepare_input($HTTP_POST_VARS['city']); $postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']); $country = tep_db_prepare_input($HTTP_POST_VARS['country']); if (ACCOUNT_STATE == 'true') { if (isset($HTTP_POST_VARS['zone_id'])) { $zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']); } else { $zone_id = false; } $state = tep_db_prepare_input($HTTP_POST_VARS['state']); } if (ACCOUNT_GENDER == 'true') { if ( ($gender != 'm') && ($gender != 'f') ) { $error = true; $messageStack->add('checkout_address', ENTRY_GENDER_ERROR); } } if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) { $error = true; $messageStack->add('checkout_address', ENTRY_FIRST_NAME_ERROR); } if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) { $error = true; $messageStack->add('checkout_address', ENTRY_LAST_NAME_ERROR); } if (strlen($street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) { $error = true; $messageStack->add('checkout_address', ENTRY_STREET_ADDRESS_ERROR); } if (strlen($city) < ENTRY_CITY_MIN_LENGTH) { $error = true; $messageStack->add('checkout_address', ENTRY_CITY_ERROR); } if (strlen($postcode) < ENTRY_POSTCODE_MIN_LENGTH) { $error = true; $messageStack->add('checkout_address', ENTRY_POST_CODE_ERROR); } if (ACCOUNT_STATE == 'true') { $zone_id = 0; $check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "'"); $check = tep_db_fetch_array($check_query); $entry_state_has_zones = ($check['total'] > 0); if ($entry_state_has_zones == true) { $zone_query = tep_db_query("select distinct zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and (zone_name = '" . tep_db_input($state) . "' or zone_code = '" . tep_db_input($state) . "')"); if (tep_db_num_rows($zone_query) == 1) { $zone = tep_db_fetch_array($zone_query); $zone_id = $zone['zone_id']; } else { $error = true; $messageStack->add('checkout_address', ENTRY_STATE_ERROR_SELECT); } } else { if (strlen($state) < ENTRY_STATE_MIN_LENGTH) { $error = true; $messageStack->add('checkout_address', ENTRY_STATE_ERROR); } } } if ( (is_numeric($country) == false) || ($country < 1) ) { $error = true; $messageStack->add('checkout_address', ENTRY_COUNTRY_ERROR); } if ($error == false) { $sql_data_array = array('customers_id' => $customer_id, 'entry_firstname' => $firstname, 'entry_lastname' => $lastname, 'entry_street_address' => $street_address, 'entry_city' => $city, 'entry_postcode' => $postcode, 'entry_country_id' => $country); if (ACCOUNT_GENDER == 'true') $sql_data_array['entry_gender'] = $gender; if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $company; if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $suburb; if (ACCOUNT_STATE == 'true') { if ($zone_id > 0) { $sql_data_array['entry_zone_id'] = $zone_id; $sql_data_array['entry_state'] = ''; } else { $sql_data_array['entry_zone_id'] = '0'; $sql_data_array['entry_state'] = $state; } } if (!tep_session_is_registered('sendto')) tep_session_register('sendto'); tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array); $sendto = tep_db_insert_id(); if (tep_session_is_registered('shipping')) tep_session_unregister('shipping'); tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); } // process the selected shipping destination } elseif (isset($HTTP_POST_VARS['address'])) { $reset_shipping = false; if (tep_session_is_registered('sendto')) { if ($sendto != $HTTP_POST_VARS['address']) { if (tep_session_is_registered('shipping')) { $reset_shipping = true; } } } else { tep_session_register('sendto'); } $sendto = $HTTP_POST_VARS['address']; $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$sendto . "'"); $check_address = tep_db_fetch_array($check_address_query); if ($check_address['total'] == '1') { if ($reset_shipping == true) tep_session_unregister('shipping'); tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); } else { tep_session_unregister('sendto'); } } else { if (!tep_session_is_registered('sendto')) tep_session_register('sendto'); $sendto = $customer_default_address_id; tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); } } // if no shipping destination address was selected, use their own address as default if (!tep_session_is_registered('sendto')) { $sendto = $customer_default_address_id; } $addresses_count = tep_count_customer_address_book_entries(); echo $doctype; echo $html_parameters; ?><head> <?php echo $meta_equiv; echo $meta_mobi; ?> <meta name="googlebot" content="noindex, nofollow" > <title>Edit/Add Shipping Address</title> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <?php echo $stylesheet; ?> <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"> <?php echo tep_draw_form('shipping_address', tep_href_link('mobile-shipping.php', 'action=update_shipping_address')); ?> <script language="javascript"><!-- var selected; function selectRowEffect(object, buttonSelect) { if (!selected) { if (document.getElementById) { selected = document.getElementById('defaultSelected'); } else { selected = document.all['defaultSelected']; } } if (selected) selected.className = 'moduleRow'; object.className = 'moduleRowSelected'; selected = object; // one button is not an array if (document.checkout_address.address[0]) { document.checkout_address.address[buttonSelect].checked=true; } else { document.checkout_address.address.checked=true; } } function rowOverEffect(object) { if (object.className == 'moduleRow') object.className = 'moduleRowOver'; } function rowOutEffect(object) { if (object.className == 'moduleRowOver') object.className = 'moduleRow'; } function check_form_optional(form_name) { var form = form_name; var firstname = form.elements['firstname'].value; var lastname = form.elements['lastname'].value; var street_address = form.elements['street_address'].value; if (firstname == '' && lastname == '' && street_address == '') { return true; } else { return check_form(form_name); } } //--></script> <?php require(DIR_WS_INCLUDES . 'form_check.js.php'); require(DIR_WS_INCLUDES . 'mobile-top.php'); echo tep_draw_form('checkout_address', tep_href_link(FILENAME_MOBILE_SHIPPING, '', 'SSL'), 'post', 'onSubmit="return check_form_optional(checkout_address);"', true); ?> <div class="contentwrapper"> <div id="contentwrapperinner"> <h1>Delivery Information</h1> <?php if ($messageStack->size('checkout_address') > 0) { echo $messageStack->output('checkout_address'); } if ($process == false) { ?> <p><?php echo tep_address_label($customer_id, $sendto, true, ' ', '<br>'); ?></p> <?php if ($addresses_count > 1) { ?> <p>Please select the shipping address below, or enter a new address</p> <?php $radio_buttons = 0; $addresses_query = tep_db_query("select address_book_id, entry_firstname as firstname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_suburb as suburb, entry_city as city, entry_state as state, entry_zone_id as zone_id, entry_postcode as postcode, entry_country_id as country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "'"); while ($addresses = tep_db_fetch_array($addresses_query)) { $format_id = tep_get_address_format_id($addresses['country_id']); ?> <table> <tr> <td><?php echo tep_output_string_protected($addresses['firstname'] . ' ' . $addresses['lastname']); ?><hr></td> <td><?php echo tep_draw_radio_field('address', $addresses['address_book_id'], ($addresses['address_book_id'] == $sendto)); ?></td> </tr> <tr> <td colspan="2"><?php echo tep_address_format($format_id, $addresses, true, '<br/> ', ', '); ?></td> </tr> </table> <?php $radio_buttons++; } ?> <p><?php echo '<a href="' . tep_href_link(FILENAME_MOBILE_SHIPPING, '', 'SSL') . '" class="ui-button">back</a>'; ?> </p> <div style="float: right;"><?php echo tep_draw_hidden_field('action', 'submit') . tep_draw_button(IMAGE_BUTTON_UPDATE, 'triangle-1-e', null, 'primary'); ?></div> <?php } } if ($addresses_count < MAX_ADDRESS_BOOK_ENTRIES) { ?> <div class="rule"></div> <h3>add / edit shipping address:</h3> <?php require(DIR_WS_MODULES . 'checkout_new_address.php'); ?> <div class="vspace"></div> <div class="alignleft"><?php echo '<a href="' . tep_href_link(FILENAME_MOBILE_SHIPPING, '', 'SSL') . '" class="ui-button">back</a>'; ?></div> <div style="float: right;"> <?php echo tep_draw_hidden_field('action', 'submit') . tep_draw_button(IMAGE_BUTTON_UPDATE, 'triangle-1-e', null, 'primary'); ?></div> <div class="clear"></div> <?php } if ($process == true) { } ?> </form> </div> </div> <?php require(DIR_WS_INCLUDES . 'mobile-bottom.php'); ?>
-
Hi I am doing a mobile version of my website www.irhtoys.co.uk/mobile-index.php it is all ok apart from I am changing one of the tabs that was Reviews to New Products I have copied the coding from my products_new.php page and is displaying the products and the prices but the prices are displaying as £0.00 Can any one help please The coding below is from my mobile-index.php <div id="categories"><div id="latestPosts-one"><div class="latestposts"> <h1>New Products</h1> <?php $products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name"; $products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW); $row = 0; $products_new_query = tep_db_query($products_new_split->sql_query); while ($products_new = tep_db_fetch_array($products_new_query)) { if ($new_price = tep_get_products_special_price($products_new['products_id'])) { $products_price = '<del>' . $currencies->display_price($products_new['products_price'], tep_get_tax_rate($products_new['products_tax_class_id'])) . '</del> <span class="productPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($products_new['products_tax_class_id'])) . '</span>'; } else { $products_price = $currencies->display_price($products_new['products_price'], tep_get_tax_rate($products_new['products_tax_class_id'])); } echo ' <div class="m productlisting"> <div class="m-image"><a href="' . tep_href_link(FILENAME_MOBILE_INFO, 'products_id=' . $products_new['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $products_new['products_image'], $products_new['products_name'], '50', '50') . '</a></div> <div class="m-name"><a href="' . tep_href_link(FILENAME_MOBILE_INFO, 'products_id=' . $products_new['products_id']) . '"><strong><u>' . $products_new['products_name'] . '</u></strong></a></div><br /> <div class="m-price">'. $currencies->display_price($new_price['products_price'], tep_get_tax_rate($products_new['products_tax_class_id'])) . '<br /></div></div><div class="clear"></div> ' . "\n"; if ((($row / 3) == floor($row / 3))) { } } ?> </div></div></div></div> The code below is from my products_new.php page if it helps <?php $products_new_query = tep_db_query($products_new_split->sql_query); while ($products_new = tep_db_fetch_array($products_new_query)) { if ($new_price = tep_get_products_special_price($products_new['products_id'])) { $products_price = '<del>' . $currencies->display_price($products_new['products_price'], tep_get_tax_rate($products_new['products_tax_class_id'])) . '</del> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($products_new['products_tax_class_id'])) . '</span>'; } else { $products_price = $currencies->display_price($products_new['products_price'], tep_get_tax_rate($products_new['products_tax_class_id'])); } ?> <tr> <td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $products_new['products_image'], $products_new['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td> <td valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id']) . '"><strong><u>' . $products_new['products_name'] . '</u></strong></a><br />' . TEXT_DATE_ADDED . ' ' . tep_date_long($products_new['products_date_added']) . '<br />' . TEXT_PRICE . ' ' . $products_price; ?><?php echo tep_draw_separator('pixel_trans.gif', '10', '50'); ?></td> <td align="right" valign="middle" class="smallText"><?php echo tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new['products_id'])); ?></td> </tr> <?php } ?>
-
Hi I have got results being displayed after clicking the search button in a form on my home page but it brings up all the results which is ok but how do I get onlt the results a user searches for for example a location or property type etc as its for a property website The coding is below for the results page Also sorry how do I add a background image to the php page, I tried using css but wouldn't work <style type="text/css"> body {background-image:url('images/greybgone.png');} </style> <?php mysql_connect ("2up2downhomes.com.mysql", "2up2downhomes_c","mD8GsJKQ") or die (mysql_error()); mysql_select_db ("2up2downhomes_c"); echo $_POST['term']; $sql = mysql_query("select * from properties where typeProperty like '%$term%' or location like '%$term%'"); while ($row = mysql_fetch_array($sql)){ echo 'Type of Property: '.$row['typeProperty']; echo '<br/> Number of Bedrooms: '.$row['bedrooms']; echo '<br/> Number of Bathrooms: '.$row['bathrooms']; echo '<br/> Garden: '.$row['garden']; echo '<br/> Description: '.$row['description']; echo '<br/> Price: '.$row['price']; echo '<br/> Location: '.$row['location']; echo '<br/> Image: '.$row['image']; echo '<br/><br/>'; } ?>
-
Any ideas any one please I am well and truly stuck Kind regards Ian
-
Hi I have managed to connect to mysql database and managed to display results but now how I want exactly I want the results to be displayed by what the customer searches as its a property website so for example, in my search form I have the following Property Type Location Number of bedrooms Number of Bathrooms Min Price Max Price for example, I put in the following House Benfleet 4 2 £100,000 £300,000 but when I click on search, it returns all the results that are in mysql database and not just what I am looking for Please help I have included the coding below <html> <body> You have searched for a <?php echo $_POST["propertytype"]; ?> <br> You have searched in the location of <?php echo $_POST["location"]; ?> <br /> You have searched for <?php echo $_POST["bedrooms"]; ?> bedrooms <br /> You have searched for <?php echo $_POST["bathrooms"]; ?> bathrooms <br /> You have searched for £<?php echo $_POST["minprice"]; ?> <br /> You have searched for £<?php echo $_POST["maxprice"]; ?> <br><br> Please find your results below </body> </html> <br><br> <?php $db=mysql_connect("host", "user", "password"); mysql_select_db("database", $db); ?> <?php $db = mysql_select_db("database") or die ("Couldnt select database"); ?> <?php // Query database $result = mysql_query("SELECT * FROM properties"); if (!$result) { echo "Error running query:<br>"; trigger_error(mysql_error()); } elseif(!mysql_num_rows($result)) { // no records found by query. echo "No records found"; } else { $i = 0; echo '<div class="container" style="float:left;">'; while($row = mysql_fetch_array($result)) { // Loop through results $i++; echo '</div>'; echo '<div class="textholder" style="font-family:helvetica; font-size:13px; float:left; padding-top:10px;">'; echo "<span style=\"color:green;\"><b>Displaying record $i<br>\n</b><br></span>"; echo "<b>" . $row['id'] . "</b><br>\n"; // Where 'id' is the column/field title in the database echo "Property Type: ". $row['typeProperty'] . "<br>\n"; // as above echo "Bedrooms: ". $row['bedrooms'] . "<br>\n"; // .. echo "Bathrooms: ". $row['bathrooms'] . "<br>\n"; // .. echo "Garden: ". $row['garden'] . "<br>\n"; // .. echo "Description: ". $row['description'] . "<br>\n"; // .. echo "Price: ". $row['price'] . "<br>\n"; // .. echo "Location: ". $row['location'] . "<br>\n"; // Where 'location' is the column/field title in the database echo '</div>'; echo '<div style="clear:both"></div>'; } echo '</div>'; } ?> Kind regards Ian
-
how to display data from the mysql database to my webpage
ianhaney replied to ianhaney's topic in PHP Coding Help
Hi Sorry Batwimp, is it ok to keep replying, if not I will stick to replying on the original post -
how to display data from the mysql database to my webpage
ianhaney posted a topic in PHP Coding Help
I have got connection to the the mysql database, how do I get the data from the database to display on the webpage -
Ok I am winning sort of, I have got connection the mysql database, how do I get the data from the database to display on the webpage
-
I am thinking of starting from scratch as is going wrong somewhere
-
I took that line out Muddy but am getting this now php_network_getaddresses: getaddrinfo failed: Name or service not known This is doing my head in now I have included my coding in below <?php //$connection = mysql_connect($host, $user, $password) or die ("Couldnt connect to server"); $db=mysql_connect("$host", "$user", "$password"); mysql_select_db("$database", $db); $db=mysql_connect("$host", "$user", "$password"); mysql_select_db("$database", $db) or die (mysql_error()); mysql_select_db("$database", $db) or die (mysql_error()) or die (mysql_error()); //Program: getdata.php //Desc: Gets data from a database using a function ?> <html> <head> <title>Properties</title> </head> <body> <?php $typeProperty = gettypeProperty("House"); //call function echo "<p><b>{$typeProperty['typeProperty']}</b><br>\n; Description: {$typeProperty['Description']}<br>\n; Price: \${$typeProperty['price']}\n"; ?> </body> </html> <?php function gettypeProperty($typeProperty) { $db = mysql_select_db("properties") or die ("Couldnt select database"); $query = "SELECT * FROM properties WHERE typeProperty='typeProperty'"; $result = mysql_query($query) or die ("Couldnt execute query."); return mysql_fetch_array($result,MYSQL_ASSOC); } ?> <html> <body> You have searched for a <?php echo $_POST["propertytype"]; ?> <br> You have searched in the location of <?php echo $_POST["location"]; ?> <br /> You have searched for <?php echo $_POST["bedrooms"]; ?> bedrooms <br /> You have searched for <?php echo $_POST["bathrooms"]; ?> bathrooms <br /> You have searched for £<?php echo $_POST["minprice"]; ?> <br /> You have searched for £<?php echo $_POST["maxprice"]; ?> </body> </html>
-
Hi I have this in my coding and have got the php error messages turned on in my control panel with my host but that's it ini_set('display_errors', 1); error_reporting(E_ALL);
-
Hi Muddy Funster Thank you for the reply I put in the coding you said and am still getting the following error Server error The website encountered an error while retrieving http://www.2up2downhomes.com/saleresults.php. It may be down for maintenance or configured incorrectly. Here are some suggestions: Reload this web page later. HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfil the request. The code I am using is below <?php ini_set('display_errors', 1); error_reporting(E_ALL); //$connection = mysql_connect($host, $user, $password) or die ("Couldnt connect to server"); $db=mysql_connect("$host", "$user", "$password") or die (mysql_error()); mysql_select_db("$database", $db) or die (mysql_error()); //Program: getdata.php //Desc: Gets data from a database using a function ?> <html> <head> <title>Properties</title> </head> <body> <?php $typeProperty = gettypeProperty("House"); //call function $f_price = number_format ($typeProperty['price',2); echo "<p><b>{$typeProperty['typeProperty']}</b><br>\n; Description: {$typeProperty['Description']}<br>\n; Price: \${$typeProperty['price']}\n"; ?> </body> </html> <?php function gettypeProperty($typeProperty) { $db = mysql_select_db("properties") or die ("Couldnt select database"); $result = mysql_query("SELECT * FROM properties") or die (mysql_error()); //$query = "SELECT * FROM properties WHERE typeProperty='typeProperty'"; $result = mysql_query($query) or die ("Couldnt execute query."); return mysql_fetch_array($result,MYSQL_ASSOC); } ?> <html> <body> You have searched for a <?php echo $_POST["propertytype"]; ?> <br> You have searched in the location of <?php echo $_POST["location"]; ?> <br /> You have searched for <?php echo $_POST["bedrooms"]; ?> bedrooms <br /> You have searched for <?php echo $_POST["bathrooms"]; ?> bathrooms <br /> You have searched for £<?php echo $_POST["minprice"]; ?> <br /> You have searched for £<?php echo $_POST["maxprice"]; ?> </body> </html>
-
Hi Thank you so much for removing the data and I will do, I am so sorry, bit new to this forum
-
Hi I am in the middle of designing a website and am trying to get a webpage to connect and display results from the database to my webpage when a customer does a search but is not working The coding is below Any ideas how to get it to work, I have been trying for hours today <?php $db=mysql_connect("2up2downhomes.com.mysql", "userxxx", "passxxx"); mysql_select_db("2up2downhomes_c", $db); $result = mysql_query("SELECT * FROM properties"); while($row = mysql_fetch_assoc($result)){ echo "ID: ".$row['id'].", Type of Property:".$row['typeProperty'] .", bedrooms:".$row['bedrooms'].", garden:.$row['garden'].", description:.$row['description'].", price:.$row['price'].", location:.$row['location']."<br/>"; } ?> <html> <body> You have searched for a <?php echo $_POST["propertytype"]; ?> <br> You have searched in the location of <?php echo $_POST["location"]; ?> <br /> You have searched for <?php echo $_POST["bedrooms"]; ?> bedrooms <br /> You have searched for <?php echo $_POST["bathrooms"]; ?> bathrooms <br /> You have searched for £<?php echo $_POST["minprice"]; ?> <br /> You have searched for £<?php echo $_POST["maxprice"]; ?> </body> </html> Thank you in advance, appreciate it Ian EDIT (KP): Removed credz & please use code tags next time