Jump to content

Bricktop

Members
  • Posts

    677
  • Joined

  • Last visited

    Never

Everything posted by Bricktop

  1. Hi runnerjp, Have a look at this tutorial which will take you through the entire process. Also, on the code you have posted, all of your fields have the same name (e.g. name="Name"), this is going to cause you problems so make sure each field is named individually (e.g. name="Name", name="Event", "name="Email" etc) Hope this helps.
  2. Hi rhodry_korb, You're right in that they wouldn't write everthing out like that, this is why you need to read the tutorials. Dynamic URL rewriting happens because the PHP application is written in that way. For example, the following Rewrite rule: RewriteRule ^news/category/([^/\.]+)/?$ /news.php?f=shownews&category=$1 [L] Will dynamically rewrite any news URL based on its category. So the one rule will allow for any number of news categories such as: http://www.domain.com/news/category/headlines http://www.domain.com/news/category/world http://www.domain.com/news/category/weather http://www.domain.com/news/category/sport You need to read up on mod_rewrite and look at how it functions, it's an extremely powerful and complex tool, the code I supplied you is merely a very basic mod_rewrite usage.
  3. Hi rhodry_korb, The tutorial I posted has all the information you need to start off with mod_rewrite, but I'll post some code for you. Firstly, you need to create an .htaccess file, and paste the following code into it: ################################################### # Turn the RewriteEngine on. # ################################################### RewriteEngine on ################################################### # Add a leading www to domain if one is missing. # ################################################### # If this rule is used, the rewriting stops here # # and then restarts from the beginning with the # # new URL # ################################################### RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] ################################################### # Do not process images or CSS files further # ################################################### # No more processing occurs if this rule is # # successful # ################################################### RewriteRule \.(css|jpe?g|gif|png)$ - [L] ################################################### # Add a trailing slash if needed # ################################################### # If this rule is used, the rewriting stops here # # and then restarts from the beginning with the # # new URL # ################################################### RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$ RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L] ################################################### # Rewrite web pages to one master page # ################################################### # /somepage/ => master.php # # ?page=somepage # # /somesection/somepage => master.php # # ?section=somesection # # &page=somepage # # /somesection/somesub/somepage/ # # => master.php # # ?section=somesection # # &subsection=somesub # # &page=somepage # ################################################### # Variables are accessed in PHP using # # $_GET['section'], $_GET['subsection'] and # # $_GET['page'] # ################################################### # No more processing occurs if any of these rules # # are successful # ################################################### RewriteRule ^aboutus/ /index.php?uri=aboutus [L] RewriteRule ^contactus/ /index.php?uri=contactus [L] RewriteRule ^anotherpage1/ /index.php?uri=anotherpage1 [L] RewriteRule ^you-can-use-hyphens/ /index.php?uri=toseparatewords [L] Now save the .htaccess file and upload it to the directory your index.php file is in. You can now navigate to http://www.domainofmine.com/aboutus and http://www.domainofmine.com/index.php?uri=aboutus will load. The above code is fully commented so should be easy to follow.
  4. Hi rhody_korb, I assume Joomla already makes use of mod_rewrite for the rewriting of all it's URL's, this is why you don't use it when using Joomla. If you want to write your own PHP website, and use the URL format you require, you will need to use mod_rewrite. The tutorial I linked to above includes code snippets.
  5. Hi rhodry_korb, You need to investigate mod_rewrite, have a look at this article which explains the process. Hope this helps.
  6. OK, add the -f to your script as below: <?php if(!$_POST) exit; $email = $_POST['email']; //$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS'; if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){ $error.="Invalid email address entered"; $errors=1; } if($errors==1) echo $error; else{ $values = array ('name','email','message'); $required = array('name','email','message'); $to_email = "martin@mcgdesignstudio.com"; $from_email = "From: mcgdesignstudio.com <martin@mcgdesignstudio.com>"; $email_subject = "New Message: ".$_POST['subject']; $email_content = "new message:\n"; foreach($values as $key => $value){ if(in_array($value,$required)){ if ($key != 'subject' && $key != 'company') { if( empty($_POST[$value]) ) { echo 'You need to fill in all the required fields...'; exit; } } $email_content .= $value.': '.$_POST[$value]."\n"; } } if(mail($to_email, $email_subject, $email_content, "-f$from_email")) { echo 'Your message has been sent successfully..'; } else { echo 'Oops, something went wrong...try again later.'; } } ?>
  7. Hi martingreenwood, Chnage your script to the below: <?php if(!$_POST) exit; $email = $_POST['email']; //$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS'; if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){ $error.="Invalid email address entered"; $errors=1; } if($errors==1) echo $error; else{ $values = array ('name','email','message'); $required = array('name','email','message'); $to_email = "martin@mcgdesignstudio.com"; $from_email = "From: mcgdesignstudio.com <martin@mcgdesignstudio.com>"; $email_subject = "New Message: ".$_POST['subject']; $email_content = "new message:\n"; foreach($values as $key => $value){ if(in_array($value,$required)){ if ($key != 'subject' && $key != 'company') { if( empty($_POST[$value]) ) { echo 'You need to fill in all the required fields...'; exit; } } $email_content .= $value.': '.$_POST[$value]."\n"; } } if(mail($to_email, $email_subject, $email_content, $from_email)) { echo 'Your message has been sent successfully..'; } else { echo 'Oops, something went wrong...try again later.'; } } ?> Changes made: 1. Changed the variable name of the "To" address to $to_email. 2. Added a new $from_email variable and added the relevant "From" information 3. Removed the extra header information 4. Rewritten the mail() command Give the above a try and report back with the result. Hope this helps.
  8. Hi j05hr, That's your problem. When you call a URL with a ? this is a pararmeter which the $_GET associative array can grab. So, with the http://localhost/estateagent/edit_subject.php?page=15 URL the parameter is 'page' and the value 'page' has is '15'. The 'page' parameter will be set when the $_GET checks for it in the following code: isset($_GET['page']) For your script to work as you want, the 'subj' parameter needs to be set, and to do this you would use a URL like http://localhost/estateagent/edit_subject.php?subj=15. However, you will need to look at how your script functions as to whether this is possible. Remember, you can have multiple parameters in a URL using: http://localhost/estateagent/edit_subject.php?page=15&subj=15 However, in this example your find_selected_page() function will still fail because both values will be set. You will need to add something like: if (isset($_GET['subj']) && isset($_GET['page'])) { //Do something } But depending on your application and how you're running it this may not be a suitable option. Hope this helps.
  9. Hi jo5hr, When you load the page, what is the exact URL in the address bar? (you can sensor the domain name if you wish)
  10. Hi joshr, $sel_subject['menu_name'] will not display unless $_GET['subj'] is set, that's how your find_selected_page() function is written: function find_selected_page () { global $sel_subject; global $sel_page; if (isset($_GET['subj'])) { $sel_subject = get_subject_by_id($_GET['subject']); $sel_page = NULL; } elseif (isset($_GET['page'])) { $sel_subject = NULL; $sel_page = get_page_by_id($_GET['page']); } else { $sel_subject = NULL; $sel_page = NULL; } } Is this set? I can't see how from the code above unless it's being set from the URL this page is loading from.
  11. Hi j05hr, The above code is a set of functions, are you able to post the code which shows how you call the above functions?
  12. Hi gator, If you simply echo out $vid_row[13] does it give the expected result? e.g. somethumbnail.jpg Also, is ../storage/movies/thumbs the correct path? Remember the paths in this script are relative to where the script is being run from. The "../" moves down a directory level. So, if you move down a folder from where this script is being run, can you then get to storage->moves->thumbs? Hope this helps.
  13. Hi kid304, Have a look at Scribd's API which should do what your require. Hope this helps.
  14. OK, but I'm guessing the directory $_GET["apId"] refers to does not exist? i.e. you would like the dorectory to be created dynamically depending on what $_GET["apId"] contains. If so, move_uploaded_file() does not create directories. To confirm this, try manually creating a correct $_GET["apId"] folder, then running the above script. The file should write to the folder as the folder now exists. Report back what happens.
  15. Does echoing out the $upload_dir variable give the expected output?
  16. Hi Steve, Give the following a try: else if ($action == "send") { // Send the email $name = isset($_POST["name"]) ? $_POST["name"] : ""; $email = isset($_POST["email"]) ? $_POST["email"] : ""; $subject = isset($_POST["subject"]) ? $_POST["subject"] : $subject; $message = isset($_POST["message"]) ? $_POST["message"] : ""; $cc = isset($_POST["cc"]) ? $_POST["cc"] : ""; $token = isset($_POST["token"]) ? $_POST["token"] : ""; //Grab the two new $_POST values and assign them to variables $attachmentname = isset($_POST["name"]) ? $_POST["name"] : ""; $attachment = isset($_POST["attachment"]) ? $_POST["attachment"] : ""; //Create a new $message variable, combining $message, $attachmentname and $attachment $message = "Message: $message\n\nAttachment Name: $attachmentname\n\nAttachment: $attachment\n\n" // make sure the token matches if ($token === smcf_token($to)) { smcf_send($name, $email, $subject, $message, $cc); echo "Your message was successfully sent."; } else { echo "Unfortunately, your message could not be verified."; } } Hopefully the above should do what you want, it will send the contents of the attachment name and attachment fields in the main email body. Hope this helps.
  17. Hi rvdb86, Try amending your code to read: move_uploaded_file($_FILES['file']['tmp_name'], "$upload_dir/$new_file");
  18. Hi robert_gsfame, It would be better to achieve this result using Javascript. Have a look at this article which explains how to achieve this result using JQuery. Another very simple option would be to. 1. Create a page called "redirect.html" and add the following code: <p>Please wait while the page loads</p> <meta http-equiv="refresh" content="5;url=http://www.mydomain.com"> 2. Edit your .htaccess file and add the following: DirectoryIndex redirect.html However, this option will always wait 5 seconds, by then the page may not have loaded, or it may have loaded in 2 seconds and the user still has to wait. It also may effect SEO ratings so I would recommend you investigate the Javascript option as this is dynamic and the loading dialog will clear once the page has finished loading. Hope this helps.
  19. Hi rvdb86, Does $_GET["apId"] contain data? Do you get the expected output if you echo this variable? Also, try adding a trailing slash to the $upload_dir variable, for example: $upload_dir = "../gallery/".$_GET["apId"]."/"; // Directory for file storing Hope this helps.
  20. OK, could you post more of the code, specifically the MySQL query and the rest of the PHP code.
  21. Hi fj1200, The value attribute for the Submit button is $job_desc, so whenever you submit this form element the contents of $job_desc is what will be posted to the database. Is this correct?
  22. Hi Stuart, Your script is relying on $_POST['posted'] to be set before performing the query. Is that set? Post your HTML to confirm. Also, your else statement is just including "news-select.php" and doing nothing else. Change your code to read: <?php if ($_SERVER['REQUEST_METHOD']=='POST') { $newsmonth = $_POST['newsmonth']; $result = mysql_query("SELECT * FROM $db_table WHERE MONTH(date) = $newsmonth ORDER BY nid DESC"); } else { $result = mysql_query("SELECT * FROM $db_table ORDER BY nid DESC"); include("includes/news-select.php"); } while($myrow = mysql_fetch_assoc($result)) {//begin of loop $nid = $myrow['nid']; $headline = $myrow['headline']; $date = $myrow['uk_date']; // Show Pulled Through News Items echo "<ul> <li> <h2><span class='newsdate'>($date)</span> <a href='newsitem.php?nid=$nid' title='$headline'>$headline</a> </h2> </li> </ul>"; } ?> Hope this helps.
  23. It's \n though, not /n. lol, ty Daniel, I knew that really......
  24. Hi Miss-Ruth, Your echo command as it stands: { echo "category=".$line["category"]."<br/>"; echo "namez=".$line["namez"]."<br/>"; echo "CN1=".$line["col1"]."<br/>"; } Will echo all three variables regardless of what's assigned to what. With XML try using /n to create a linebreak, like so: { echo "category=".$line["category"]."/n"; echo "namez=".$line["namez"]."/n"; echo "CN1=".$line["col1"]."/n"; } If you only want "category" to be echo'd just do: { echo "category=".$line["category"]; } But I'm not sure what implications this will have on your application, you may want the other data to be echo'd out.
  25. Hi Miss-Ruth, It depends on where you are outputting this info (on an HTML page or via XML) but adding a line break will work if you're echoing to HTML. Change your code to read: { echo "category=".$line["category"]."<br/>"; echo "namez=".$line["namez"]."<br/>"; echo "CN1=".$line["col1"]."<br/>"; } Hope this helps.
×
×
  • 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.