TySkby 41 Junior Poster

These functions seem to be along the line of what you're looking for:

  • strrpos
    Find the position of the last occurrence of a substring in a string
  • substr
    Return part of a string

So, you could use strpos to find where the last . character occurs in the string example.org/some_file.zip, and then use substr to get the part of the string that comes after that character (which would be zip in this case).

Hope that helps!

TySkby 41 Junior Poster

For working on a few files or making quick edits, usually Notepad++ does just fine.

When I'm working on a project, Netbeans is definitely my choice. Especially if I'm working with a 3rd party utility, API, or framework, I really appreciate that it gives me the ability to view in-line documentation and look up those functions/methods/objects. It definitely shines in situations where I might find myself spending time digging through extensive documentation (the Drupal framework, for instance) that would otherwise require a back-and-forth between my editor and browser.

I've used Eclipse as well and think it's fairly equal to Netbeans, although for whatever reason I've tended to stick with Netbeans.

TySkby 41 Junior Poster

I would say it would be a concern.

Generally, you want to keep the front end as far away from the back (eg. your database) end as possible. Especially if it's for ecommerce where you could be handling some sensitive data on your site (but even just in general), I think keeping your front-end code for building forms and pages from touching your database is important.

TySkby 41 Junior Poster

I'd say that's probably a matter of opinion and experience, but for me personally, OOPHP is what I consider to be "advanced".

It's more about advanced vs basic tasks for me, and I think that's independent of any language. The best solution for any job may be simple, for others it may be more involved and require knowledge of things like array manipulation, reference variables, and the like. But the most important thing is enhancing your ability to learn and familiarize yourself with new concepts and always be on the lookout for the best solution to any particular task at hand.

TySkby 41 Junior Poster

I'm a hobbyist-gone-pro, and I can share some of the feelings of intimidation when it comes to learning concepts like OOP, MVC, and new frameworks.

I'd advocate for the approach where you do it yourself (at least the first time), especially with an MVC approach. It's incredibly valuable to be able to understand how classes and methods work, and for me, the best way to do that was to do it without a framework. It helped me learn the basics by building off my existing knowledge.

Once I had that under my belt, I went ahead and started learning how to use some of the frameworks. I'm glad I did because it really does speed up development in many cases. As always, pick the best tool for the job, but considering a framework as a potential tool can be very helpful.

If you're new to the whole framework thing, I'd suggest starting with CodeIgniter. It's a lot like CakePHP, but much more flexible when it comes to doing things that aren't strictly "The Framework Way". Don't get me wrong- Cake is good too, but I think as a beginner's framework (and a pro's), CodeIgniter is definitely the way to go.

TySkby 41 Junior Poster

Suppose user have JS disabled!

I personally don't support non-JS browsers most of the time, and I'd agree with broj1's 3rd suggestion ("let know the user that he can not participate").

Many (most) sites are incredibly dependent on javascript to function properly, even if they do offer 'graceful degradation'. While that should almost always be something to strive toward, let's be realistic- who is browsing your site with javascript disabled? If someone knows enough to disable javascript in their browser, they probably know enough to turn it back on when it's necessary. It's easy enough to have a message telling a user that they must have javascript enabled to use a site, or a part of a site.

Javascript is at the point where it really is a necessity for browsing the web. I wouldn't worry about a user having javascript disabled- it's unlikely in the first place, and it's silly to spend time offering workarounds for something that really is a basic part of web technology.

Just an opinion, but one I feel is worth considering.

TySkby 41 Junior Poster

No, I will not write the script for you (and I doubt you'll find anyone here who will). This is a forum for learning.

However, if you are looking to have someone write scripts for you, try posting it as a job. Since programming is a professional skill, most people expect to get paid or otherwise compensated for writing code for others.

If you are interested in learning how to do this yourself, what I can tell you is that the reason there is nothing other than an IP address in your email is that the variable $message is empty. Decide on what you want to fill the body of your email with, and then set $message to that text.

You can either do it with a static line of text:

$message = "Thank you for subscribing!";

Or with other variables from the form:

$message = "Thank you, $name $surname, for subscribing!  We will contact you with the email address you provided: $email.  Have a great day!"
TySkby 41 Junior Poster

On line 565 of the code you posted before, I see this:

mail("sales@propertylinkng.com", 'Subscription Form: '.$subject, $_SERVER['REMOTE_ADDR']."\n\n".$message, "From: $from");

Which would explain why all you're seeing is an IP address, because you are putting a concatenation of $_SERVER (the IP address), then "\n\n" (two new lines), and finally $message.

The problem here is that I don't see the $message variable declared or set with a value anywhere. If you do that, you'll probably start seeing more than an IP address in the body of your email.

TySkby 41 Junior Poster

Can you provide which CMS you are using, or any code you are using to process the data submitted in your FCKeditor form? The issue is probably due to something with one (or both) of those two things, especially if your CMS (or one of its plugins) was updated recently.

Have you tried outputting the text immediately after it has been submitted to your form handler? That could help in figuring out whether it actually is FCKeditor that is escaping tags, or if there is some code involved in processing that is doing it.

TySkby 41 Junior Poster

Are you running this on a remote server or from your own machine's localhost?

If you are testing on localhost (or if your remote server doesn't have PHP mail configured) you are likely to have issues sending mail.

TySkby 41 Junior Poster

I don't think you need to change anything except a few tweaks to your HTML form and the way PHP handles the value from the radio buttons.

Both radio button elements should have identical name attributes. In the value attributes, one button should be set to 'Chicago' and the other to 'Dallas'. So in your form you'd have something like this:

<input type="radio" name="origin" value="Chicago" /> Chicago <br />
<input type="radio" name="origin" value="Dallas" /> Dallas <br />

Then, you should add another variable (I'll call it $origin for consistency) and set it the same way you set the $destination variable, like this:

$origin = $_POST['origin'];
$destination = $_POST['destination'];

In your if/else statements, you can then do something like

if ($origin == 'Dallas' && isset($_POST['destination'])
{
  //Dallas code
}
else if ($origin == 'Chicago' && isset($_POST['destination'])
{
  //Chicago code
}
else
{
  //...
}

One last thing I'd recommend is that you do your isset() checks where you set the $destination and $origin variables.

//Declare you variables as empty here to prevent errors
$origin;
$destination;

//Check that there is a value for 'origin' and 'destination'
if (isset($_POST['origin']) && isset($_POST['destination']))
{
  $origin = $_POST['origin'];
  $destination = $_POST['destination'];
}

That will allow you to keep things neat and separated by doing all of your form validation in one place, and will also prevent errors from showing up in case the user failed to make a selection for 'origin' or 'destination'.

Hope that helps!

TySkby 41 Junior Poster

On line 7 of your code, you set

$destination = $_POST['destination']

That is correct, but now you don't need to use the $_POST variable anymore to reference that value. So the problem is in lines 9, 10, 17, and 18 where you are doing $_POST[$destination] because what that really works out to is $_POST[$_POST].

So if you alter your references a bit, you should be good. Try applying this to the lines mentioned above (here I'm using what should go on lines 9 and 10):

if (isset($_POST['dal'])  && isset($_POST['destination'])) {
	$distance = $cities[$destination];
TySkby 41 Junior Poster

No apology necessary! We're all here to help and be helped :)

To elaborate, when I suggested adding comments to your code, I was thinking something a bit more in-line that would elaborate what your code is doing step-by-step. You can use // to comment and document a single line of code in PHP and JavaScript.

Here's an example:

<script>
//Arrays for Image URLs, titles, and captions
var imageUrl = new Array(); 
var imageTitle = new Array();
var imageCaption = new Array();

<?php
//Explain what the $counta and $count variables are, and what this loop does here
for($counta=0; $counta<$count; $counta++)
{
echo "imageTitle[".$counta."]=\"".$imageTitle[$counta]."\";";
echo "imageUrl[".$counta."]=\"".$imageURI[$counta]."\";";
echo "imageCaption[".$counta."]=\"".$imageCaption[$counta]."\";";
}

?>

//Here you can tell readers why you are using jQuery.noConflict()
jQuery.noConflict();

jQuery(document).ready(function() {

//Tell us what var a is and what it will be used to do
var a=0;

//Give some details on this function here
function changepicture() {
jQuery("#slideshowpicture img").attr('src', imageUrl[a]);
jQuery("#slideshowtitle").html(imageTitle[a]);
jQuery("#slideshowarticle").html(imageCaption[a]);
jQuery(".dot"+a).attr('src', "<?php echo $templateuri; ?>/images/home/dotw.jpg");

//What are you checking for here?
if( a == 0) {
a++;
jQuery(".dot<?php echo $count-1; ?>").attr('src', "<?php echo $templateuri; ?>/images/home/dotb.jpg");

}
//What is the alternative?
else if( a == <?php echo $count-1; ?>) {
b = a - 1;
a = 0;
jQuery(".dot"+b).attr('src', "<?php echo $templateuri; ?>/images/home/dotb.jpg");
}
else {
b=a-1;
a++;
jQuery(".dot"+b).attr('src', "<?php echo $templateuri; ?>/images/home/dotb.jpg");
}
}
changepicture();
var slideinterval = setInterval(changepicture, 4000);
});
</script>

Those are just some places where I personally could use some clarification. Commenting is really good practice for allowing others to understand what …

TySkby 41 Junior Poster

I seem to jump on threads that ardav has posted on a lot, but I wanted to chime in here just to advocate the usage of print_r() and var_dump() when struggling with an array-related issue.

I consider these two functions to be extremely useful, and personally can say that once I started using them, my understanding of (multidimensional) arrays was greatly improved.

TySkby 41 Junior Poster

Definitely check out this link for extra info on usage and syntax: http://php.net/manual/en/function.preg-match.php

Using this will require a bit of knowledge of regex (REGular EXpressions), which can be a pain and confusing at first, but definitely good to be familiar with, as regex can be used in many languages.

Essentially, using preg_match() will allow you to check a string for a matching pattern. For instance, you can search comments that people submit for a pattern that would be common to links, such as 'http://', 'www', '.com', etc. Then you can search for the pattern in the comment being posted and if it finds a match for something like 'http://somesite.com' or 'http://www.somesite.org' or anything like that (it depends on the regex you are searching for), you can either reject the post or replace the matching substring with some text like 'LINK REMOVED'.

Here are some good examples and resources to help you:


http://RegExLib.com is a great place to find already-written regular expressions that you can use in your code.

^[a-zA-Z0-9\-\.]+\.(com|org|net|mil|edu|COM|ORG|NET|MIL|EDU)$
This is a regex pattern that will match valid URLs in a string. I found it here: http://regexlib.com/REDetails.aspx?regexp_id=25

Also, you may want to read the thread at http://stackoverflow.com/questions/1141848/regex-to-match-url. People have posted some good regex patterns to match what you are trying to do.

Hope that helps! Regex can be tough, but knowing it and/or knowing where to find examples are …

TySkby 41 Junior Poster

Some comments to document your code and a little bit of extra information about your specific question/issue would go a long way. I did read through the code you posted, but it's a bit unclear (to me, at least) as to what you are attempting to do (which is why I suggest adding some comments to your code to help make it more understandable to an outside reader).

I'd love to help with this, but some clarification would definitely be useful. I can obviously only speak for myself, but I think that would help generate a better response from the members here- I know it would for me :)

TySkby 41 Junior Poster

MySQLi (MySQL Improved) is a PHP driver for MySQL databases that offers functionality more commonly desired in Object-Oriented programming. It may be useful if you are using Object-Oriented PHP (OOPHP), but for smaller stuff it's mostly a matter of preference. The developers of PHP seem to recommend the MySQLi driver over the "regular" MySQL driver.

In terms of frameworks, I would suggest you start by learning something like CodeIgniter. It's fairly easy to get the hang of if you're looking to develop OOPHP applications and allows for a lot of flexibility in how you do things (like how you can use a MySQL database). Like any other framework, it's not for every job, but it's a good one for MVC (Model-View-Controller) applications.

Zend is another commonly used framework that is part of many PHP installations by default.

PEAR also comes with many PHP installations. It offers functionality common to many PHP applications and is a really useful tool to have on your belt. PEAR can be used alongside/with other PHP frameworks.

Another framework that I haven't personally used a lot is CakePHP. Some argue that it requires a bit more discipline and advanced knowledge of PHP since it can be stricter than something like CodeIgniter, but it is another example of a very good MVC framework for PHP.

Hope that gives you some extra useful knowledge. I'd recommend researching and reading about this stuff to give you a more in-depth understanding …

cereal commented: well explained +7
TySkby 41 Junior Poster

Not sure what you were trying to do, but since this forum is a community for learning, it would be nice if you could post your solution so that others could learn from it as well :)

TySkby 41 Junior Poster

I can see a problem with the structure of your if/else conditions. Currently your innermost code where you calculate $time and $walktime and print your outputs will only be executed if $_POST and $_POST are both set. If I'm understanding what you want to do correctly, the user would select either 'Chicago' or 'Dallas', but not both.

So the first thing you'll need to fix will be changing your code structure to be

if (isset($_POST['dal']) && isset($cities['destination']))
{
  //Put your code for Dallas as the selection here
}
else if (isset($_POST['chi']) && isset($cities['destination']))
{
  //Put your code for Chicago as the selection here
}
else
{
  print "Please select a Starting city and a Destination.";
}

A few other things you'll probably want to check for:
-Are the Starting city and the Destination city the same? You'll probably want to add 'Chicago' => 0 to $cities and 'Dallas' => 0 to $cities2 or else you'll get an error.
-Where are you setting the value for $cities? Do you mean to be checking isset($_POST) instead? If that's the case, you'll want to alter the code where you set $distance to be more like:

$distance = $cities[$_POST['destination']]

...assuming that the value of $_POST is a value in your $cities or $cities2 arrays.

Other than that, the idea of how you will find the distance between to cities looks to be pretty solid. It looks like you just need to tweak the structure a bit for everything to work.

TySkby 41 Junior Poster

If I'm reading this correctly, you have been able to split the string variable $str into an array. Assuming you have named the new array $str_array, you could do something like this:

-Iterate through the array and for each value in $str_array, use strlen() to count the number of characters in the current value
-Compare it to the existing longest value (we'll call it $longest). If it is larger, check if it's in the $area array.
-If it is, replace the value of $longest to be the value of the current iteration.

With this method, you'd come out with something similar to the following code:

//Set the $longest variable to be an empty string for now
$longest = '';

//Iterate through $str_array with the current iteration set to $value
foreach($str_array as $value)
{
	//Get the length of $value
	$length_value = strlen($value);
	//Get the length of $longest
	$length_longest = strlen($longest);
	
	//Compare the lengths
	if ($length_value > $length_longest)
	{
		//$value has more characters than $longest, so check if it is in $area
		if (in_array($value, $area))
		{
			//$value is a value of $area array, so make it the new value for $longest
			$longest = $value;
		}
	}
}

At the end of this loop, $longest will be equal to the longest word that exists in both $str_array and $area arrays.

Obviously this could be shortened down to be more efficient and such (and I would encourage you to do that), but I figured it would help more people …

asif49 commented: Offered great help! +3
TySkby 41 Junior Poster

Awesome, thanks- that makes a lot of sense.

And yeah, I knew that my script would fail since there are calls to variables in other functions. I just wanted a quick example to show what I meant.

For me, an additional benefit of attaching handlers in javascript is the ability to see what's going on "at-a-glance" (ok, sometimes a pretty big glance).

Yeah, outside of the efficiency thing, that's something I would consider a huge benefit. It sucks to have to hunt around for every "onclick" event in the document body when you're not sure what all they might be. Definitely simpler to see them all defined at the top.

Thanks for clearing that up- I feel smarter already!

TySkby 41 Junior Poster

Excellent example, Airshow- that's pretty much what what I was going to suggest.

I do have one question, since you mentioned efficiency in your example and I was curious about it- could you explain a bit more? Specifically with this part of the example:

<script type="text/javascript">
onload = function(){
	var addSingle = document.getElementById("addSingle");
	var addDouble = document.getElementById("addDouble");
	var singleRow = document.getElementById("singleRow");
	var doubleRow = document.getElementById("doubleRow");
	var extraRows = document.getElementById("tbody1");
	addSingle.onclick = function(){
		var r = singleRow.cloneNode(true);
		extraRows.appendChild(r);
		return false;
	};
	addDouble.onclick = function(){
		var r = doubleRow.cloneNode(true);
		extraRows.appendChild(r);
		return false;
	};
};
</script>

I understand why it's more efficient to define the vars "singleRow", "doubleRow", and "extraRows" in the onload closure. But why is it better to have "addSingle" and "addDouble" defined there, as opposed to something like this:

<script type="text/javascript">
var singleRow = document.getElementById("singleRow");
var doubleRow = document.getElementById("doubleRow");
var extraRows = document.getElementById("tbody1");

function addSingleRow(){
	var r = singleRow.cloneNode(true);
	extraRows.appendChild(r);
	return false;
};

function addDoubleRow(){
	var r = doubleRow.cloneNode(true);
	extraRows.appendChild(r);
	return false;
};
</script>

and then have this in the HTML <body>:

<th><button id="addSingle" class="add" onclick="addSingleRow();">Single</button></th>
<th><button id="addDouble" class="add" onclick="addDoubleRow();">Double</button></th>

I'm basically just curious (not critical)- why would the extra declarations and the anonymous functions be better than no declarations for those two button elements with named functions? Would you mind explaining that?

Thanks,
Ty

PS- Not my intention here to hijack this thread- if the OP would like me to make this another discussion, I'd be happy to do so.

TySkby 41 Junior Poster

Then there's some decisions to make here.

One thing you could do is add the rows locally (on the client side) and then once everything is complete, have another button (eg. "Save") that actually submits the form and saves the data to mysql.

Another solution(which would be a bit more advanced) would be to incorporate some Ajax functionality into your existing buttons, so that when they're clicked they make a call to a PHP script that saves the current form data to mysql, and then when it calls back successfully, you go ahead and run the javascript necessary to add the new row (and all of this would happen without reloading the page, since you'd be using Ajax). You would probably still want a save button for when you're all done but don't want to add any more rows.

TySkby 41 Junior Poster

You will need to set an event that fires when each button is clicked. You should give your buttons id attributes in their HTML tags.

In the javascript, make a function that, depending on the id of the button that was clicked, appends the HTML for a new row consisting of one or two new list boxes.

So if "Double" was clicked, you would add:

<tr>
  <td>
    (Markup for one list)
  </td>
  <td>
    (Markup for one list)
  </td>
</tr>

To the bottom of your table. Also, you should have the buttons return false when they are clicked so you don't submit the form each time. I'm not exactly sure about what you're doing with this form, but if this is a purely javascript question (with no server-side processing necessary), you don't want to submit the form each time the buttons are clicked or else the page will reload, which will reset the form to its original state.

TySkby 41 Junior Poster

Not usually on a properly-configured server with SMTP.

In the past, I have found that it sometimes works on a local machine if you configure the SMTP line in php.ini to point to the SMTP server of your ISP.

Sometimes it works, sometimes it doesn't- depends on your ISP and what kinds of restrictions they have on their SMTP server (usually whether they require SMTP authentication).

So if you have, say, Comcast as your ISP and their SMTP server address is "smtp.comcast.net" on port 25, you could try changing your php.ini file so that it reads like this:

SMTP = smtp.comcast.net
smtp_port = 25

Feel free to try that out, but don't be surprised if you don't have any luck. Also, I should note that the above php.ini configuration is for Windows. Unix servers rely on the "sendmail_path" line for that configuration. But that's only if you have sendmail set up on your server.

Oh, and if you do try that out, remember to save a backup of php.ini first. You probably know that already, but I feel obligated to say it, knowing the hell I've put myself through by messing with php.ini without a backup.

TySkby 41 Junior Poster

What about listing each video link, and when the link is clicked it opens up in a foreground frame (eg. Fancybox) that loads the video based on parameters sent to the frame via javascript?

That way, when the foreground frame is closed, it could trigger a function that stops or pauses the video.

TySkby 41 Junior Poster

I've set up a home server (as far as I know it's called that). I'm using xampp and use "localhost/" to access the page on google chrome.

Are you saying that if this was hosted on the web then this problem would dissapear?

Most likely. Every time I've encountered this problem, it is resolved as soon as it is hosted on a server with a SMTP.

TySkby 41 Junior Poster

Found it!

I know you've already made some progress on this, but if you want to take a look, either for ideas or to use part of the code, here's the link: http://github.com/TySkby/WikiFB

If you have any questions, I'm happy to help. Good luck!

TySkby 41 Junior Poster

*Edit- I understand now after thoroughly reading page 2.

I'm going to do some hunting- I wrote a PHP application that does almost this exact same thing. When I find it, I'll put a link to the source files if you'd like.

TySkby 41 Junior Poster

I know this is marked as solved but I've done this before and wanted to add my two cents if I may.

I have a custom CMS that does this, and here is my process, which I feel is pretty simple, as all images can be in the same directory:
1. Save the original file name to a variable ($name)
2. Generate a unique name to replace the file. I used rand() as part of a loop that checks the database to make sure the random number isn't already in use. If the loop finds a match, it starts over again with a new rand().
3. When you've got your unique random number, rename the file with that number and save it to your preferred directory.
4. Save the original file name ($name) to your database together with the new file name.
5. For display purposes, you can use the original file name (like "kitchen.jpg") so the user can identify the image. But in your business logic, you actually only use "kitchen.jpg" for display- file management uses the random file name generated above.

Hope that helps someone!

karthik_ppts commented: Thanks for sharing +5
TySkby 41 Junior Poster

There are lots of ways to do this, but here's a relatively simple example. Maybe others can chip in a few other ways of doing this.


1. Create a new nullable column in MySQL 'profiles' table (maybe call it 'reset_token')
2. If a user needs a password reset, give them a form to type their email address and hit 'submit'.
3. When the form is submitted, generate a random unique value for 'reset_token' and save it to that user's row in MySQL. Then send an email with the 'reset token' value to the user and a link that takes them to a password reset page.
4. On the password reset page, have a form for the user to type their email address, their provided reset token, and a new password.
5. When that form is submitted, check to see that the reset token matches with the email address in the 'profiles' table. If it does, md5() encrypt the new password and replace the old encrypted password with the new one.

almostbob commented: like it +13
TySkby 41 Junior Poster

Agreeing with almostbob here. A registration email with a reset password link/form would be best for security.

Additionally, if you are storing an encrypted form of the password in the database, it's not possible* to retrieve the original password. The point of encrypting it is that only the original password will match an md5 encryption. It's good that the password is encrypted in the DB, and it really makes almostbob's solution the most appropriate way to reset your users' passwords.


*By which I mean 'not feasible' or 'not possible in theory'.

TySkby 41 Junior Poster

Don't replace the single quote with doubles, in line 20, the issue is with the double quotes in border="0". Those should be changed to single quotes, as seen here:

<?php


  $groupname = $_REQUEST['groupname'] ;
  $info = $_REQUEST['info'] ;
  $size = $_REQUEST['size'] ;
  $special = $_REQUEST['special'] ;
  $firstname =$_REQUEST['firstname'] ;
  $lastname = $_REQUEST['lastname'] ;
  $address1 = $_REQUEST['address1'] ;
  $address2 = $_REQUEST['address2'] ;
  $city = $_REQUEST['city'] ;
  $prov = $_REQUEST['prov'] ;
  $email = $_REQUEST['email'] ;
  $phone1 = $_REQUEST['phone1'] ;
  $phone2 = $_REQUEST['phone2'] ;
  $phone3 = $_REQUEST['phone3'] ;
  $website = $_REQUEST['website'] ;
  
$message = "<table width='600px' border='0' cellspacing='3' cellpadding='3'>
  <tr>
    <td><strong>Groupname :</strong></td>
    <td>$groupname</td>
  </tr>
  <tr>
    <td><strong>Info :</strong></td>
    <td>$info</td>
  </tr>
  <tr>
    <td><strong>Size :</strong></td>
    <td>$size</td>
  </tr>
  <tr>
    <td><strong>Special :</strong></td>
    <td>$special</td>
  </tr>
  <tr>
    <td><strong>Firstname :</strong></td>
    <td>$firstname</td>
  </tr>
  <tr>
    <td><strong>Lastname :</strong></td>
    <td>$lastname</td>
  </tr>
  <tr>
    <td><strong>Address1 :</strong></td>
    <td>$address1</td>
  </tr>
  <tr>
    <td><strong>Address2 :</strong></td>
    <td>$address2</td>
  </tr>
  <tr>
    <td><strong>City :</strong></td>
    <td>$city</td>
  </tr>
  <tr>
    <td><strong>Prov :</strong></td>
    <td>$prov</td>
  </tr>
  <tr>
    <td><strong>Email :</strong></td>
    <td>$email</td>
  </tr>
  <tr>
    <td><strong>Phone1 :</strong></td>
    <td>$phone1</td>
  </tr>
  <tr>
    <td><strong>Phone2 :</strong></td>
    <td>$phone2</td>
  </tr>
  <tr>
    <td><strong>Phone3 :</strong></td>
    <td>$phone3</td>
  </tr>
  <tr>
    <td><strong>Website :</strong></td>
    <td>$website</td>
  </tr>
</table>" ;
  $headers  = "From: ".$email."\r\n";
  $headers .= 'MIME-Version: 1.0' . "\n";
  $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	
  mail( "user@mailserver.com", "Vendor Application",
    $message, $headers );
  header( "Location: http://www.thewebsiteimlinkingto.ca/thanks!.html" );
  
  
?>

Hope this helps! :)

TySkby 41 Junior Poster

Hello there, and welcome to DaniWeb.

I'm not a moderator or anything other than a regular old poster here, but I can tell you that two things will not get you the help you are looking for:

1. Requesting things to be made for you. As I understand it, this forum is for people who are looking for help and/or advice concerning their code/configurations/errors, etc.

2. Spamming the forum by making one thread and then making the exact same one a bit later with the word 'URGENT!!!!!!'.


I'm not trying to be a jerk here- this is just my understanding. And my perception is that you are requesting that contributors to this forum 'make code' for you, and that you demand it be done quickly (lest you create a new thread insisting you receive help sooner). Having urgent projects that require immediate assistance is why people hire programmers, or extra programmers. And if you're looking for a pre-made script, then that's what search engines are for.


However, I for one would be quite happy to assist you if you could provide some code that you are having issues with and needed help looking it over, or had a question about a concept or methodology. If you're asking about pre-made scripts, maybe you have a list of certain possibles and would like some help deciding which one to use?

TySkby 41 Junior Poster

So, are you just wanting a counter for each page, or something that tracks the links that each individual visitor clicks on?

So basically, is this site-specific or user-specific?

TySkby 41 Junior Poster

You could make an object in JavaScript for each node you need and define whether it's an absolute parent (has no ancestors), a parent and a child, or an absolute chile (has no descendents). Then have a method that sets an array to define the arrays in parents, and when you instantiate it, give it a reference to the instantiation's DOM selector.

After you do that, set up a script in jQuery (what I would do at least) that goes and decides what type of node everything is and calls the methods that instantiate the objects based on where they are your ancestral order.

TySkby 41 Junior Poster

Sorry that this is not completely specific to your problem, but since you said "Unfortunately, it's the regex I've been struggling with. I trying to do this
'a_key'(whitespace)=>(whitespace)'(content_to_replace)' for it, but I'm going around in circles."

Might I suggest something like Regex Buddy? Regex always hurts my head, and I find that the tool is something that reduces that from the level of a nasty migraine to a run-of-the-mill headache.

Only problem is that it's not free. So you may want to check out this thread for some alternatives.

diafol commented: Good links - cheers +13
TySkby 41 Junior Poster

Something that may make configuring easier, but in the past I've seen this issue resolved by changing the SMTP setting in php.ini to the SMTP server of your ISP.

I don't think that fixes it 100% of the time (I'm sure it has something to do with your ISP as well), but it may be worth a shot. You can usually find your ISP's SMTP server address by doing a quick Google search.

TySkby 41 Junior Poster

Try this: http://jqueryfordesigners.com/coda-slider-effect/

It uses jQuery and does a pretty good job of things. I've used it and liked it a lot. Plus, you can customize it to your heart's content fairly easily after it's all set up.

TySkby 41 Junior Poster

Nope, I'm pretty sure that's all you need, as ardav said.

TySkby 41 Junior Poster

Ok, as I thought. You're accessing your stuff through the browser as a local file and not through the server.

Remeber that a browser can only read HTML, JavaScript, and other client-side code. PHP is server-side, so you need to access it through your server (on 'localhost').

The solution to your issue depends on your Xampp installation, so if you installed Xampp to the location 'C:\Xampp' (which is default), you should go to 'C:\Xampp\htdocs' and in there, make a folder (I'll call it 'bureaublad' in this example) and paste your 'index.php' and 'login.php' files into that folder.

Then (as long as Xampp and Apache are running), you should be able to access you code with a URL like 'http://localhost/bureaublad/index.php'.


Currently, since you're accessing the files directly in your browser instead of letting them be processed through the server, the server isn't being asked to do anything and you can't use PHP as a result (because PHP needs to be processed through the server- it can't be done by the browser alone).

TySkby 41 Junior Poster

I think it may be your data flow (not sure because I haven't tested it), but I believe this will work:

if (Todays_Date >= Target_Date) {
        clearTimeout(timeoutID);
        alert("Timeup, Submitting exam....");
        $('#testForm').submit();
        return;
    }

or, if that doesn't work, try this:

if (Todays_Date >= Target_Date) {
        clearTimeout(timeoutID);
        var timeup = alert("Timeup, Submitting exam....");
        if (timeup) {
                $('#testForm').submit();
        }
        return;
    }

I'm not sure what the 'return;' is for either, if it's not being set to anything.

Have you read this: http://api.jquery.com/submit/ ?

TySkby 41 Junior Poster
<form name=form1 method=post action=send_contact.php>
<p>Emne:</p><input name=subject class=input type=text id=subject size=64>
<br /><br />
<p>Forespørgsel:</p><textarea name=detail cols=50 rows=7 id=detail></textarea>
<br /><br />
<p>Navn:</p><input name=name class=input type=text id=name size=64>
<br /><br />
<p>Email:</p><input name=customer_mail class=input type=text id=customer_mail size=64>
<br /><br />
<input type=submit name=Submit value=&nbsp;Send&nbsp;> <input type=reset name=Submit2 value=&nbsp;Ryd formen&nbsp;>

You don't have quotes in your html- that will stop things from working at all until that gets fixed, I believe.

TySkby 41 Junior Poster

Quick question- are you accessing these pages with 'localhost' in your URL? The reason I ask is because you said you were getting the full code in Chrome, which shouldn't happen if you're accessing the pages through your Xampp server.

TySkby 41 Junior Poster

Can you be more specific about what you mean by "protecting"? Do you mean you want to hide/obscure the variable or its params from the user, or something else, like making your application securely use a $_GET variable?

TySkby 41 Junior Poster

What are you currently setting the cookies' expiration date to? If you don't set it to anything, then they will expire automatically when the browser closes.

If you're trying to automatically log the client out after, say, 15 minutes of inactivity, then you will need a system to monitor the user's actions and log when the last action (like loading a new page) took place.

TySkby 41 Junior Poster

I think you need something like this:

$extract = mysql_query("select * from tbl_competition WHERE fld_closed='N'");

if (mysql_num_rows($extract) > 0) {
    while ($row = mysql_fetch_assoc($extract)) {
        //Do your thing with the data
    }
} else { //No rows from MySQL
    //Put your redirect stuff here
}

And yeah, where are your {} and all the code for what you want to happen during the while() loop?

TySkby 41 Junior Poster

I'll admit, I don't know much about using Dreamweaver for stuff like that (and I have CS4), so I don't know how Advanced Recordset works.

However, I've found that Dreamweaver lacks in the PHP department (I only ever use it for HTML when I'm too lazy to do it by hand), in my opinion. Again, I don't have CS5, so maybe it's better, but if I were to make a suggestion, it would be to skip learning the Dreamweaver-specifics and make it easier on yourself by learning the MySQL functions for PHP. Sometimes I think Dreamweaver over-complicates things (again, just a personal observation).

Maybe try out NetBeans IDE with PHP so you can get the code suggestion and syntax highlighting, which I found made things much easier when I was learning PHP.

But back to your original question, I think something like what vibhadevit posted would be good to use. Since you're new to PHP, here's the code tweaked a little so you can see what it's doing step-by-step and with comments for clarification:

<?
if (isset($_POST['search'])) { //If the form's "Submit" button was clicked...
    echo 'Search Result :<br />';

    //Set variables to info posted from the form
    $width = $_POST['width'];
    $profile = $_POST['profile'];
    $size = $_POST['size'];

    //Escape the strings so they're safe to use in a MySQL query
    $width = mysql_escape_string($width);
    $profile = mysql_escape_string($profile);
    $size = mysql_escape_string($size);

    //Start building the query
    $where = " 1=1 ";

    if ($width != "") {  //If the user selected a …
TySkby 41 Junior Poster

That have something to do with installation than PHP/MySQL. Just uninstall the whole thing and reinstall it!

+1 for this idea.

I would hazard to guess that you may have 2 MySQL installations going, since WAMP usually includes that in the installation, but much easier to just get a fresh start, I would think.

TySkby 41 Junior Poster

NetBeans, definitely.

Others may say Eclipse or Aptana, but I personally prefer NetBeans for PHP. Netbeans also supports Zend, CodeIgniter, Symfony, as well as others via plugins.