PDA

View Full Version : مشکل با url ؟



redhat2
پنج شنبه 17 اسفند 1391, 11:55 صبح
سلام به دوستان ، من یه همچین فرمی دارم ، فرض کنید url من ای هست :
localhost/index/index که اولی Controller ودومی action هست ،
این فرم من هست :
index.tpl :


<html>
<head>
<title></title>
</head>
<body>
<form action="index/index/" method="GET">
<h2><?php echo $title; ?></h2>
<input type="text" name="username" />
<input type="submit" value="login" />
</form>
</body>
</html>


خوب وقتی من توی صفحه کلیک میکنم url این شکلی میشه :


http://localhost/index/index/index/index/?username=saeed

نمیخوام اینطوری بشه ، میخوام اینطوری بشه :


http://localhost/index/index/?username=saeed

باید چیکار کنم؟ ، درضمن میخوام بدونم من اگه یک Action داشته باشم به نام Register میخوام که به action دیگه ای به نام login منتقل بشه ، آیا تابعی هست هر دوی این Action ها ماله indexcontroller هست .

2hamed
پنج شنبه 17 اسفند 1391, 12:13 عصر
از آدرس کامل استفاده کنید:



<html>
<head>
<title></title>
</head>
<body>
<form action="http://localhost/index/index/" method="GET">
<h2><?php echo $title; ?></h2>
<input type="text" name="username" />
<input type="submit" value="login" />
</form>
</body>
</html>




یا اینکه اگر اپلیکشنتون همیشه تو روته یک / به ابتدای url اضافه کنید. که البته توصیه میشه همه جا از آدرسهای مطلق (روش بالا) استفاده کنید.


<html>
<head>
<title></title>
</head>
<body>
<form action="/index/index/" method="GET">
<h2><?php echo $title; ?></h2>
<input type="text" name="username" />
<input type="submit" value="login" />
</form>
</body>
</html>

mamali-mohammad
پنج شنبه 17 اسفند 1391, 13:54 عصر
متد روی GET هست
روی POST بزار تا درست بشه