In order to keep the script from running when the form is displayed, you have to start it with something like:
if(isset($_POST['form']['submit'])) {
(if you don't have a button called \"submit\", replace that word with the name of your submit button or any field that is sure to have a value.) I don't know why RSForm doesn't already include that conditional or something similar, since the script is to be run only on form process, but it doesn't, so you have to do it.
As for sending the page title and URL in an email: I know that the RSForm notification email functionality sends a plain text email, not HTML, but most email clients will make a link out of anything they recognize as a URL. So I would think you could put the title and URL in a hidden field in the form (as well as the page title), and populate it either with the Default Value setting (I don't know if there is a way to access the mainframe object there or not) or Javascript in the \"script on form display\" that runs after the page is built. Then use the field placeholders in RSForm's \"Emails\" section to put it in the email body. Does that help, or am I not understanding what you want to do?