
Twistedweb123
Members-
Posts
21 -
Joined
-
Last visited
Contact Methods
-
Website URL
http://twistedwebsolutions.com
Profile Information
-
Gender
Male
-
Location
England, UK
Twistedweb123's Achievements

Newbie (1/5)
1
Reputation
-
Trying To Add / Hide Certain Menu Links Using Php
Twistedweb123 replied to kjetterman's topic in PHP Coding Help
Looking at your code, there seems to be no actual credential in place to check if a user is actually "logged in", but rather just what url they are on. By this logic, I do not need to login anyway, but just visit a certain page of your website? This needs to be recoded. Before you look into seperate menus for users based on their url, you should first look at seperate menus for users based on a login credential, such as a cookie or PHP session. If you use cookies, my browser will be updated with information telling your script I am either a logged in, or out. Rather than checking the URL to see this fact, we check my cookie. If no cookie exists - I am logged out. If a cookie exists but has expired - I am logged out. If a cookie exists and is active - I am logged in. Then, based on the status of my cookie, you can show the appropriate menus. You also need to secure the validation of your cookie and make sure it refences something (such as correct login credential in a database), otherwise I could just set a cookie in my browser to access your site. I have probably over-explained it and gone into too much detail security wise for a newbie, but it is good to plug these mistakes early on. My best suggestion would be looking into PHP sessions. Check out this free resource: http://www.phpeasystep.com/phptu/6.html and from here, you can probably see the if statements which determine a users status. From there, you can show menus depending on that. -
Hi, so this is my issue. I have written this is htaccess to redirect all my xxx.html to /xxx on my site. However, I know this effects directories. If i visit mydomain.com/admin/ i get a 404 error, but if i visit mydomain.com/admin/index.php it is fine. This is fine, but I have an issue with my blog directory (it is running wordpress). How do I write a mod rewrite query to not effect the blog directory, as mydomain.com/blog/index.php redirects to mydomain.com/blog/ ... this then looks for blog.php which doesnt exist. I'm open to all suggestions. Here is my current code: RewriteEngine on RewriteRule ^([^/\.]+)/?$ $1.php [L]
-
I am working on a poject, where the search functions doesnt work as the user wishes. The coding is technically correct, but the idea behind it is wrong. Basically at the moment, the script receives this: thesite.com/search.php?q=xxxx&Submit=Search The search script then runs a database query to search the tag coloumn, looking for like $q. This would work, however the structure of the coloumn is tag1, tag2, tag3, tag4. So my resolutions is this so far: I explode the $q variable, via the + (if you search more than one term "thesite.com/search.php?q=search+stuff&Submit=Search" I then count the elements in the array and write the database function accordingly $var = @$_GET['q'] ; $trimmed = trim($var); $searchpieces = explode("+", $trimmed); $dbquery=""; $count = count($searchpieces); for ($i = 0; $i < $count; $i++) { if($i == 0){$dbquery.="tags = $searchpieces[$i]";} elseif($i > 0){$dbquery.=" OR tags = $searchpieces[$i]";} } So my database query is $sql = "select * from gallery where $dbquery order by date DESC " . $limit; so my question is this.. how to i eplode the tags database coloumn, so my datase query an look at each tag fro "tag1, tag2, tag3" as "tag1" "tag2" "tag3" I am not even sure if this is possible, but its the system that is already in place. The problem with the current system, is because the pictures have alot of tags and the database query is $like $q, it just shows all images in the database as the result
-
Yeah, i personally do, but his form is just to email and no database is involved
-
Can I ask why you want to move each one individually up and down? An easier method would be to put the up/down arrows on every coloumn header, then link in a sort with that. So if you click the up arrow in date, it sorts ascending, and down would sort descending. If you put the arrows on all coloumn headers, you could sort by every coloum header rather than individual rows
-
slight error in my last post change: $headers = "From: $from"; to: $headers = "From: $email";
-
I believe you are confusing how the mail() function works. The mail functions requires certain inputs to send. Such as: email address to deliver to email address delivered from the subject the message email headers <?php if(isset($_POST['submit'])) { $to = '[email protected]'; $subject = "New Message"; $name = $_POST['name'] ; $email = $_POST['email'] ; $adresse = $_POST['adresse'] ; $telefon = $_POST['tele'] ; $unternehmensname = $_POST['uname'] ; $unternehmenstyp = $_POST['unternehmenstyp'] ; $betreff = $_POST['betreff'] ; $anschreiben = $_POST['anschreiben'] ; $headers = "From: $from"; $message = " See information from form below,\n\n Name: $name\n Email: $email\n Adresse: $adresse\n Telefon: $telefon\n Unternehmensname: $unternehmensname\n Unternehmenstyp: $unternehmenstyp\n Betreff: $betreff\n Anschreiben: $anschreiben\n\n\n"; // Send the message $sendit = @mail($to, $subject, $message, $headers); if($sendit){ header("Location: /restaurant-kontakt-gesendet.html"); }else{ header("Location: /restaurant-kontakt-error.html"); } } ?>
-
so before you moved to hostclear, the script wasnt working on godaddy?
-
To make a very quick fix, place this code ABOVE the form process function form($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return $str; } This is a quick function (that ive named form) that will clean your input.
-
Mail Form Redirect to Thankyou Page - php newbe
Twistedweb123 replied to Marcus2000's topic in PHP Coding Help
Try this out <?php if(isset($_POST['submit'])) { $to = "me@my_email_address.com"; $subject = "Contact Form"; $name = $_POST['name']; $comp_name = $_POST['company_name']; $email = $_POST['email']; $phone = $_POST['contact_number']; $location = $_POST['location']; $message = $_POST['message']; $body = "From: $name\n E-Mail: $email\n Company Name: $comp_name\n Contact Number: $phone:\n Location: $location:\n Message:\n $message"; $sendit= @mail($to, $subject, $body); if($sendit){ header('Location: yourlocation'); }else{ echo "Email failed to send";} } ?> the header can be defined in numerous ways. If you want it to go to a new site, write header('Location: http://www.thesite.com/'); if you want it to go to a page in the same directory as yours, do something like this header('Location: thankyou.php'); -
Which host are you using? phps inbuilt mail function is great, however some hosting companies are cracking down on how it is used. for example, godaddy is very unreliable when it comes to using mail(). mail usually doesnt get sent, or is very very delayed. This is due to godaddy being accussed of spam etc due to spamming customers. To make mail work on hosts such as godaddy, you need to look into using something like pear & php's mail together. look here: http://pear.php.net/
-
it is showing an error, as you are calling an undefined function form() form() is not a inbuilt php function, so if you wish to use it, you must define what you want it to do. I'm guessing, that you may want it to sanitize your inputs, stripslashes etc? If not, to fix, simply remove form( & ) from around the post variables. If you are trying to sanitize, tell me and ill show you an example function to do so
-
Unfortunatly the above code didnt work, as the server always looked for the users.php file, no matter was was entered. However I hve fixed this myself. I had a little play around, and im not sure how dity this code is, but it works for me RewriteEngine on RewriteRule ^([^/\.]+)/events/?$ events.php?artist=$1 [L] RewriteRule ^([^/\.]+)/tours/?$ tours.php?artist=$1 [L] RewriteRule ^([^/\.]+)/photos/?$ photos.php?artist=$1 [L] RewriteRule ^([^/\.]+)/videos/?$ videos.php?artist=$1 [L] RewriteRule ^([^/\.]+)/bio/?$ bio.php?artist=$1 [L] RewriteRule ^([^/\.]+)/fans/?$ fans.php?artist=$1 [L] RewriteRule ^([^/\.]+)/related/?$ related.php?artist=$1 [L] RewriteRule ^([^/\.]+)/?$ $1.php [L] As you can see, if manually entered the files which the user will have a url for - photos, videos, bio etc. I have then written a rewriterule for all files to be accessible in the server as mysite.com/xxx
-
I'm new to mod rewriting techniques, so this is a little advanced for me, but very easy for anyone with experience. Basically I am making a website, where i want to give users their own directory upon signup through mod rewrite. so rather than: mysite.com/users.php?username=xxx They can visit mysite.com/xxx I havnt written the code yet, but im pretty sure I can manage that. The trouble I am having is as follows. Basically, within their username, I want them to have a profile (similar to facebook) in the style that you can click photos, view a small bio, events they are hosting etc. So I want to turn (example:) mysite.com/bio.php?username=xxx mysite.com/photos.php?username=xxx mysite.com/events.php?username=xxx to mysite.com/xxx/bio mysite.com/xxx/photos mysite.com/xxx/events any help will be greatly appreciated