Jump to content

PHP Form


mcmuney

Recommended Posts

I'm trying to figure out the direct url of the form result page. The code below returns the form results; however, the url remains unchanged. For example, on domain.com, on submit, it remains as domain.com, but it returns form results. I'd like to know the direct path of the result page. I've tried domain.com/index.php?url=abc.com and a few others, but none work.

 

<script type="text/javascript">
function validate_url(o,e){
//var patu = /^(((ht|f)tp(s?))\:\/\/)?(www.|[a-zA-Z].)[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,4}){1,2}(\:[0-9]+)*(\/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$/i;
//var patd = /^[a-zA-Z][a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+$/i;
var patu = /^(((ht|f)tp(s?))\:\/\/)?(www.|[a-zA-Z0-9].)[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,4}){1,2}(\:[0-9]+)*(\/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$/i;
var patd = /^[a-zA-Z0-9][a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+$/i;	
R=$("#frm1url").val();
if(R && R.length>0 && R.match(patu)!=null){
	return true;
}else if(R && R.length>0 && R.match(patd)!=null){
	return true;
}else{
	alert("Invalid url entered");
	return false;
}
}
</script>
<form action="index.php" method="post" onsubmit="return validate_url(this,event)" style="padding:0px;margin:0px;">
<div id="search" style="padding:20px; width: 700px;">
<input class="input" type="text" name="url" id="frm1url" size="52" style="padding:5px;" value="Enter domain name or web page address" onblur="if (this.value == '') {this.value = 'Enter domain name or web page address';}"  onfocus="if (this.value == 'Enter domain name or web page address') {this.value = '';}">
</div>
</form>

Link to comment
Share on other sites

The form is using the POST method which doesn't show anything in the URL. If you want those variables to show up in the URL, you can change the method property to method="get". Of course, you will have to change how the php hangles the data.

Link to comment
Share on other sites

there are several ways to get form data with javascript, when using method=get (default if you just remove the "method" statement from the form tag) you can take location.url, split it at "?", take the second value and split it at "&", then take each value seperately, split them at "=" limitting to 1 split and parsing those values into variable=value... and in method=post with SOME webservers javascript can do a request(ID)  to get the value (such as on the first page <input type=text id=username> and on the second page <script> vart user = request('username');document.write("Hello there " + user); </script>

 

 

hope this helped... theres form validation for method=get on javascriptkit.com i think.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.