Jump to content

Love2c0de

Members
  • Posts

    364
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Love2c0de

  1. Good evening, I have a contact form which when submitted, gets processed inside my main index.php file and inserts into the database via a separate file for my query, 2 directories above this file. When it's time to insert, we go into this file and after the query, check to see the affected rows. At the minute, I am using a header() redirect to prevent the user being able to submit data multiple times so easily with the warning message which we get. I set a $confirmation message variable in the query script which is supposed to be displayed underneath the form but because of the header() is obviously not displaying. I could always write the query script in the main index.php file but I don't think this is good for the structure and security. My only options I see here are to either redirect them to a 'Message Confirmation' page, set a session variable - but I know for sure it's not good practice to do it this way, or process the form in the index.php file but again the issues mentioned above, I will not be exploring this avenue. Any thoughts? Kind regards, L2c.
  2. Checked the logs and it was to do with the required statement within the insert_contact.php script. Thanks very much for all the feedback everyone. Kind regards, L2c.
  3. Your answer would be to store the $_POST['phone'] value into a variable and use that variable for the remainder of the script? Kind regards, L2c.
  4. I'm guessing you mean within the query string? I've changed the column names from double to single and it is still doing the same thing. I believe I have all the permissions set correctly now after researching it. I've tried turning error_reporting and display_errors both on but it doesn't seem to be showing me an error. After changing the quotes to single quotes I no longer get the 500 error but it's still not loading. Kind regards, L2c.
  5. Good evening. Having some problems with a contact form on my page. Not sure if it's a permissions problem and/or a .htaccess problem. Everything works fine on every page that I have apart from when I submit the contact form. I've managed to work out that my code successfully get's to the echo just before require statement which is supposed to insert the data into a database. Here is my form: <form method="post" action=""> <fieldset> <legend>TSPV-Websites</legend> <p><label for="name">Name:</label><input type="text" id="name" name="name" value="<?php if(isset($_POST['name'])){ echo htmlspecialchars($_POST['name']); } ?>" /> <span>* Required</span></p> <p><label for="phone">Phone:</label><input type="text" id="phone" name="phone" value="<?php if(isset($_POST['phone'])){ echo htmlspecialchars($_POST['phone']); } ?>" /> <span>* Required</span></p> <p><label for="email">Email:</label><input type="text" id="email" name="email" value="<?php if(isset($_POST['email'])){ echo htmlspecialchars($_POST['email']); } ?>" /></p> <p><label for="referrer">Referrer:</label> <select name="referrer" id="referral_list"> <option name="default">Choose an option...</option> <option name="search_engine">Search Engine</option> <option name="facebook">Facebook</option> <option name="twitter">Twitter</option> <option name="friend">Friend</option> <option name="other">Other</option> </select> </p> <p><label class="last_label" for="comments">Comments:</label><textarea name="comments" rows="7" cols="35"><?php if(isset($_POST['comments'])){ print($_POST['comments']); } ?></textarea></p> <p class="form_btns"><input type="submit" value="Send" /><input type="reset" value="Clear" /></p> </fieldset> </form> Here is my process code: //Process the contact form if(isset($_POST['name'])) { foreach($_POST as &$v) { $v = trim($v); } if($_POST['name'] == "" || $_POST['phone'] == "") { $error = "<span class='error'>Please fill in both required (*) fields.</span>"; } //replace non numeric characters with an empty string. $_POST['phone'] = preg_replace('/[^0-9]/', '', $_POST['phone']); //check length of string after replace function. $len = strlen($_POST['phone']); if($len < 10 || $len > 11) { if(isset($error)) { $error = str_replace("</span>"," ",$error); $error .= "<br />Please enter a valid number</span>"; } else { $error = "<span class='error'>Please enter a valid number.</span>"; } } if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { if(isset($error)) { $error = str_replace("</span>"," ",$error); $error .= "<br />Please enter a valid email</span>"; } else { $error = "<span class='error'>Please enter a valid email.</span>"; } } if(!isset($error)) { //no errors, we have required data - continue echo "dasdsa"; //require("core/queries/insert_contact.php"); } } My insert_contact.php script looks like this: <?php require("./set_vars.php"); $date = date("Y-m-d", time()); echo $date; $conn = new mysqli($host,$user,$pass,$db) or die("Error creating connection."); $stmt = $conn->prepare("INSERT INTO contact ("name","phone","email","referrer","comments","date") VALUES(?,?,?,?,?,?) ") or die("Error preparing."); $stmt->bind_param("", $POST_['name'], $_POST['phone'], $_POST['email'], $_POST['referrer'], $_POST['comments'], $date); $stmt->execute(); ?> and my .htaccess looks like this: RewriteEngine on RewriteBase / RewriteRule ^/?([a-zA-Z_]+)$ index.php?page=$1 [L] When I remove the comment on the require() line, it takes me to a blank white page, the <title> or nothing is loaded and in Firebug's console, it is giving me a 500 internal server error. I've changed permissions around and it's not working so I'm really stuck as to what it could be. Anyone encountered this problem before? Thanks for your time. Kind regards, L2c.
  6. Much better solution to what I had, thanks for the input!. Kind regards, L2c.
  7. Hi requinix, Thanks for the rapid response. I carried on after making the post and came up with this: $digits = array('0','1','2','3','4','5','6','7','8','9'); $len = strlen($_POST['phone']); $phone = &$_POST['phone']; for($x = 0; $x < $len; $x++) { $char = $phone[$x]; if(!in_array($char, $digits)) { $phone = str_replace($phone[$x], "", $phone); } //combats offset issue due to replacing to an empty string shortens length of string. $len = strlen($phone); } var_dump($_POST['phone']); It returns the string containing just numbers, which is really what I want, just numbers. Are you saying I should just leave it as it is, as they input it? Kind regards, L2c.
  8. Welcome to this great forum.
  9. Good mornng all, I have a simple contact form which ask for some details from the user including name, number, email, referrer and any comments they may have: <form method="post" action="?page=Contact"> <fieldset> <legend>TSPV-Websites</legend> <p><label for="name">Name:</label><input type="text" id="name" name="name" value="<?php if(isset($_POST['name'])){ print(htmlspecialchars($_POST['name'])); } ?>" /> <span>* Required</span></p> <p><label for="phone">Phone:</label><input type="text" id="phone" name="phone" value="<?php if(isset($_POST['phone'])){ print(htmlspecialchars($_POST['phone'])); } ?>" /> <span>* Required</span></p> <p><label for="email">Email:</label><input type="text" id="email" name="email" value="<?php if(isset($_POST['email'])){ print(htmlspecialchars($_POST['email'])); } ?>" /></p> <p><label for="referrer">Referrer:</label> <select name="referrer" id="referral_list"> <option name="default">Choose an option...</option> <option name="search_engine">Search Engine</option> <option name="facebook">Facebook</option> <option name="twitter">Twitter</option> <option name="friend">Friend</option> <option name="other">Other</option> </select> </p> <p><label class="last_label" for="comments">Comments:</label><textarea name="comments" rows="7" cols="35"><?php if(isset($_POST['comments'])){ print($_POST['comments']); } ?></textarea></p> <p class="form_btns"><input type="submit" value="Send" /><input type="reset" value="Clear" /></p> </fieldset> </form> I want to convert the phone number into an integer but keep losing the preceeding 0's and I've just entered a mobile number example: 07973 762 960 and after I get redirected back to the form (because of an invalid email), it shows only: 7973. Not sure what to do. My database field is set to string for a phone number but I want to change it to int. I want to perform some checks on the phone number to make sure it contains 10 or 11 digits and starts with a 0. I realize there are string functions to check first characters of a string and length but need it to be an integer once sent to database and this issue will arise then. My form processing code is: //Process the contact form if(isset($_POST['name'])) { foreach($_POST as &$v) { $v = trim($v); } if($_POST['name'] == "" || $_POST['phone'] == "") { $error = "<span class='error'>Please fill in both required (*) fields.</span>"; } $_POST['phone'] = str_replace(array("(",")","-"),"",$_POST['phone']); $len = strlen($_POST['phone']); var_dump($len); $_POST['phone'] = (int) $_POST['phone']; if(!ctype_digit($_POST['phone'])) { if($len < 10 || $len > 11) { if(isset($error)) { $error = str_replace("</span>"," ",$error); $error .= "<br />Please enter a valid number</span>"; } else { $error = "<span class='error'>Please enter a valid number.</span>"; } } } if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { if(isset($error)) { $error = str_replace("</span>"," ",$error); $error .= "<br />Please enter a valid email</span>"; } else { $error = "<span class='error'>Please enter a valid email.</span>"; } } if(!isset($error)) { //no errors, we have required data - continue } } Thank you for you time and guidance. Kind regards, L2c.
  10. Fastsol wins, don't do my option, it was rushed as well - bacon! Kind regards, L2c.
  11. Good evening, $options = ""; for($x = 0; x <= 5; x++) { $options .= "<optiion value='201{$x}'>201{$x}"; } Then in your HTML form put: <form> <select> <?php print($options); ?> </select> </form> Kind regards, L2c.
  12. Thanks again Kevin, answered my question precisely. Kind regards, L2c.
  13. Good evening Kevin, Firstly, thank you very much for the detailed response. The idea came to me when I saw a gap in the market for companies with very low budgets to spend and no web presence whatsoever. I wouldn't say I'm 100% technically eligible to be classed as a web designer/deverloper, including the fact I can only work part time on this (at this moment in time), I realize that I cannot charge expensive prices for what I can deliver so it's imperative to undercut opposition. Sure I can write some PHP and jQ and the other required languages and can create semi-decent sites, but I still seek help regularly on a range of topics from various online forums - possibly for problems you would find very simple, which would indicate I'm not quite there yet. I do believe I can give value for money for the type of businesses I will be targeting ( generally I would assume they would be mostly static pages with some dynamic and interactive functionality, to the extent which I believe I could cope, nothing majorly over complicated ), which is why I have decided to do this to generate some extra income - in need of desktop! I really just wanted to know whether for certain types of sites such as basic static pages if there was a 'general' price you would initially have in mind to give the client. A static HTML website could be coded in a night or 2 going fully at it - with the assistance of coffee and many multi-packs of crisps of course - so I wouldn't see the need to charge the 'standard' price, rather reduce it. I'm guessing there is no definite answer for the question I'm asking, you generally price the website dependent on the client needs and taking into account the problems you stated above with bugs etc? Thanks again, Kind regards, L2c.
  14. Good evening all, When deciding on prices for clients, would you create price plans as a generic outline or do you tailor each price to each clients requirements? For example: 1 page website = £200 (made up) Fully dynamic website = £500 (made up) I have been searching and searching websites which offer web design/development services and to answer my own question......it looks like it would be No, as I haven't found one which does it yet, but I wanted to be very clear from people who are professionals in the field and get real feedback. If the answer is no, is it possible/viable - and in my interests - to provide the user with an estimated quote? Imagine being quoted £200 by code dependent on provided form data only to speak to an employee to find out it will actually be £300. Wouldn't be a very happy chappy I wouldn't have thought. Thanks for taking your time to help and advise me. Kind regards, L2c.
  15. Good evening, Just gone through the replies again. Is checking both checkdnsrr() and gethostbyname() in conjunction with each other a sufficient way to check availability? I'd rather not use an already available package but rather try it myself. Just looking for anything extra which has not been covered? Not 100% sure on how to use the WHOIS application within my own website. Kind regards, L2c.
  16. Good morning, I checked on my host and it has a WHOIS page where you can check domains. I noticed at the very bottom of the return value it says this: NOTE: THE WHOIS DATABASE IS A CONTACT DATABASE ONLY. LACK OF A DOMAINRECORD DOES NOT SIGNIFY DOMAIN AVAILABILITY. I also remember I asked about hashing passwords on here and was told to use an existing package such as PHPass. Is this one of those occasions where it would be better to use something already available. Looking into a few various pages from google, seems quite a task. Kind regards, L2c.
  17. Good morning, I am doing a domain checker part to a site and researched a little. Found gethostbyname() function and noticed that if a domain exists for example www.google.com, it returns the IP address, and when one doesn't exists for example www.googledsahtggdfg.com, it returns the string entered. I know I could write code to check the string value and work out whether it is in use or available but need some more advice. Is this sufficient checking for whether a domain is available or is there further things I should be looking at? Thank you for your time. Kind regards, L2c.
  18. Good evening, Thanks for the reply. We ended up going with Premium Account as it is probably best decribes what we offer. Pro account doesn't sound quite right. Thanks for your response. Kind regards, L2c.
  19. Good morning all, What is the typical term for an 'upgraded account on a website? I see a lot of the 'Premium Account' term used but I wanted to know what other similar words are used to describe the above? Thanks for your time. Kind regards, L2c.
  20. The site is up and we process data provided via the CQC which is updated automatically and have retrieved data for health services such as dentists, doctors, hospitals, mental health and rehabilitation. I'm just looking to market our forum really and get users visiting there regularly. We have 10,000 users registered and no one has used it so far. I suppose this is a general marketing question seeking some answers from people who have professionally done this type of work. I know there are marketing forums out there but I thought I'd ask here as this forum is usually where I find my answers. Kind regards, L2c.
  21. Good evening, Oh sorry, I thought that I put it in the first post but when I came back, it wasn't there. I presumed I forgot so re-added it. I just thought posting a link would help anyone willing to help to better understand the whole website. I gave a brief description. Just wanted some guidance from anyone who has some knowledge/experience in marketing things, the places to go, the things to do etc. Kind regards, L2c.
  22. It's a website based Health & Social Care which helps people find services they require in order to maintain independent living. We also provide recruitment for care groups and agencies and a way for them to advertise empty beds within their care home. Thank you for your time. Kind regards, L2c.
  23. Good morning, I'm just thinking about my computer resources and I'm thinking I'm going to have to invest in a desktop to run all these extra programs. Got many programs on a half decent laptop but it's starting to take it's toll in terms of performance. Would be very handy as I've spent the last 3 weeks in my new flat with no internet so it would have been very handy to have then as I was writing 2 email scripts at the time. Can anyone link me to a page for cheap desktop computers and give me a price range of what's expensive and what's not as I'm a first time buyer. I want add ons like Excel, Word, Outlook for work purposes and something which I can game on, but more importantly something I can develop on. Thanks for your time. Kind regards, L2c.
  24. Good morning everyone, I work for a website company and we are trying to get our Forum to be actively used by users. Can you provide me any kind of tips whatsoever on how to bring people to our Forum? Are there places I can market the forum? Thank you for your time. Kind regards, L2c.
  25. Good evening, No never any experience with them. Can you post a link to a tutorial/resource. Searched Google but don't know what I'm specifically looking for. Kind regards, L2c.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.