I don't know if this is possible, but I want to submit information using POST with a link. I know I can use GET, and I know I can use a form with a hidden value and submit it with a link, but I don't want either of those. I need to be able to do something like

<a href="mysite.com/submit.php" target="_BLANK" value="$id">Submit</a>

Also, doing it without JS would be nice. :)

Is this possible? Thanks.

Hm, i dunno if i understand you correctly but here is what i would do.
Instead of using <a> tag to make a submit link why not just do it the normal way
whit <input type="button"> and remove the design whit CSS. The only way that comes to mid
if you want to use <a> not 100% sure but you would have to use onclick event and js to submit
the form...

Think this may be the simplest solution.

Go whit like:

<input class="striped-button" type="submit">Submit</input>

And the just use CSS to remove its background image leaving just the plain
text "submit". Think CSS went like this:

.striped-button {
      background:none;
}
Member Avatar for diafol

Few ways to do it, but I suggest using a CSS on the submit button (to keep it all semantic) or you could do a js submit on link click.

href="javascript: sendform();"

Your function then:

<script>function sendform(){ document.formName.submit(); }</script>

Obviously, change formName to the name attribute of your form.

To correct my self there is no way of doing it whit <a> whit out using JS.
So the easiest way is just to restyle the <input type="submit"> by removing
its background image and you will get the plain text as if it was <a>.

Hello guys..

Calebcook sorry, but that sounds just like you want to hack a site.. :\
What the hell are you codding mate?

the first rule of programming is: keep it simple... And there is no simple way to do what you want!

The only simple way I recall to do that is using FLASH forms.. :D

Best regards

Ajax ?

Member Avatar for diafol

Did I deserve the downvote? :)

@migcosta: No, I'm not trying to hack. :) I'm trying to allow subscribers for my email newsletter to click on a link which takes them to a web version of the email. Rather than use GET, (e.g. mysite.com/web-version.php?emailId=3) I'd like to use POST (e.g. mysite.com/web-version.php). I tried using a form with a hidden input with the email id as the value and then submit the form with a link, but it alerts the user saying that you're about to submit an unsecured form. So, that's why I posted this question. :)

:) I see.. you can do it like this..
use a htacess redirect

email link : mysite.com/web-version/jun/
and the htacess would redirect the request to mysite.com/web-version.php
and on the php file you can detect what is in front of the expression "web-version" (in the url) and then you will have your id (jun = 3 or what ever :) )...

this way you wont have to deal with forms and you can over pass the emails limitations..

:)

:) I see.. you can do it like this..
use a htacess redirect

email link : mysite.com/web-version/jun/
and the htacess would redirect the request to mysite.com/web-version.php
and on the php file you can detect what is in front of the expression "web-version" (in the url) and then you will have your id (jun = 3 or what ever :) )...

this way you wont have to deal with forms and you can over pass the emails limitations..

:)

I see... Do you know of any sample scripts? I'm just starting PHP now, and I'm having some trouble. :)
Also, does that show the email on my-site.com/web-version.php or my-site.com/web-version.php?id=3? I need the first one. :)

Thanks!

Member Avatar for diafol

If you go down this route, you'll need a mod_rewrite

http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteRule

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^emailid=(.*)$ [NC]
RewriteRule ^(.*)$ /email/$1/%1? [R=301,L,NE]

I haven't tried it though. Hmm, I'm not the sharpest tool in the box when it comes to regex.

When uploading .htaccess files, you may get a problem. You can upload (FTP) it as htaccess.txt then rename it to .htaccess once on the server.

Nice on ardav :)

But I will recommend calebcook to start with one other thing in mind..
calebcook this will be very helpful if you intend to develop web sites...

Do you know what is a SEF? (search engine friendly urls) if not.. google it..

You can use the SEF structure to build your email links (its cleaner and nice looking) :)

please read carefully the above links they have examples and code
http://www.akchauhan.com/create-search-engine-friendlysef-websites-in-php-using-url-rewriting/

http://www.techtalkz.com/programming/180-php-sef-urls.html

I hope that helps :)

Nice on ardav :)

But I will recommend calebcook to start with one other thing in mind..
calebcook this will be very helpful if you intend to develop web sites...

Do you know what is a SEF? (search engine friendly urls) if not.. google it..

You can use the SEF structure to build your email links (its cleaner and nice looking) :)

please read carefully the above links they have examples and code
http://www.akchauhan.com/create-search-engine-friendlysef-websites-in-php-using-url-rewriting/

http://www.techtalkz.com/programming/180-php-sef-urls.html

I hope that helps :)

Thanks for all your help! :)

I guess I can use that, but I wanted to have the id POST to my-site.com/web-version.php so that any email could be viewed there, but only from a link in the email. Because if I use GET, the user could go from my-site.com/web-version.php?id=3 to my-site.com/web-version.php?id=5 or something and get an email that wasn't intended for them. It would be nice if the link posts the id so that it's a little more secure. Thanks for your help!

Caleb

:)
You can be creative on that.. example

my-site.com/web-version.php?id=5
could be equal to:
my-site.com/emails/code1/code2/

code1 => it could stand for the id:
(id = 1) = 'the-best-deal' -> =>my-site.com/emails/the-best-deal/code2
(id = 2) = 'become-millionaire'-> =>my-site.com/emails/become-millionaire/code2

code2 =>it could stand for the user group identifier or a unique identifier:
ie:
'california-users' -> => my-site.com/emails/the-best-deal/california-users
'portuguese-users' -> => my-site.com/emails/become-millionaire/portuguese-users

Then you can check (on the php file) if the califormia-users can access the 'the-best-deal' (id=1) or not...

This way you wont have clients trying to access different contents because this is a 2 codes verification..
Example: if a california dude tries to change the url to something like
my-site.com/emails/the-best-deal/portuguese-users
it wont get any content because to access the code1 (id=1) you need to have a valid code2 (in this case 'california-users')..

the usage of a numeric id on the url it's an invitation for the users to try and change the numbers.. with words.. well.. that is harder.. and the user wont even try :D

best regards

One thing I did is made it so that it'll also have the email in the url (my-site.com/web-version.php?id=1&email=me@example.com). It'll check to see if the email is in the database, and then let them view the email if it is. I suppose I could do letters as well, or add another field, such as the first name to make it better, but I'm thinking that'd be kinda' crazy. :)

Thanks for all the help!

Member Avatar for diafol

Check that the '@' is urlencoded to '%40' when you looka the html.

hum.. 2 small things..
1 - ardav is correct..
2 - using that url.. will surely send your emails to spam or "garbage".. the email companies don't like the use of tracking variables :( I had some problems in the past with that on google and hotmail emails..

best regards and good luck on you project :)

:) I see.. you can do it like this..
use a htacess redirect

email link : mysite.com/web-version/jun/
and the htacess would redirect the request to mysite.com/web-version.php
and on the php file you can detect what is in front of the expression "web-version" (in the url) and then you will have your id (jun = 3 or what ever :) )...

this way you wont have to deal with forms and you can over pass the emails limitations..

:)

That works-Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.