Link to home
Start Free TrialLog in
Avatar of Abhinav Choudhary
Abhinav Choudhary

asked on

Showing url in body tag

How can i show my url path in my body tag
If i am on a page example.com/abhinav
How can i show "abhinav" in<body>You are at "abhinav"</body>

and i also want a form action type code when i write in it like my name and click submit so it opens url.com/myname
i mean just whatever i write in form action that shows me in my url after slash
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Abhinav Choudhary
Abhinav Choudhary

ASKER

Okay Thanx its working but how can i remove the trailing slash now as it is showing You are at /path
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can u elobrate the form code because i want something like this after submit is clicked
User generated imageUser generated image
Let's keep the question to one item at a time. That way it is not confusing and does not turn into something else.

Your question about, How can i show "abhinav" in<body>You are at "abhinav"</body>

Is that answered?  Then I touched on how to use formaction and method like
<form action="url.com/myname" method="get">

Open in new window

and that would end up similar to
<form action="url.com/myname" method="get">
Answer me this 
<input type="text" name="answer">
<button type="submit">Submit</button>
</form>

Open in new window

https://www.w3schools.com/tags/att_form_action.asp
From this and your other questions, it seems that you may be new to web development.  We all were new to it once, and most of us had to dig through a lot of online internet sludge to find the good learning resources.  In the PHP topic area, we have an article that will help you clear away the sludge and learn the PHP part of things.  
https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html

Before you start PHP you would want to have a sturdy foundation in HTML5 and CSS3, as well as a good basic understanding of JavaScript.  It helps to have some foundation in the principles of computer science, too.
Scott I have understood everything u told me but about the form code
I want the url to be look like example.com/abc
when i write "abc" and click submit in form
but ur code is showing me takesme to the page of http://example.in/url.com/myname?answer=abc 
i just want it simply /abc no question mark and no equal to sign
I think URL rewriting is not a PHP question.  You might want to post a follow-on question in the Apache zone.
Agree with Ray.  Now  you are asking about url re-writing.

Let's look at your original question, how to place the page in the body using php and how to use a form. Those have been answered. Close out this question, then ask a new question about url rewriting.   When you do, make sure to let the Experts know if you are using Windows (iis) or Linux (Apache).   Detail out your url structure looks like  http://example.in/url.com/myname?answer=abc and you want the url to be converted to  http://example.in/abc.  

Just as a quick hint you can ask more about in your next question, I suggest using a micro framework like https://www.slimframework.com/ or https://lumen.laravel.com/ Then it is just a matter of adding a simple htaccess or web.config on your index file.