Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-07-2012, 09:24 AM   PM User | #1
gayathri
New Coder

 
Join Date: Nov 2012
Location: chennai
Posts: 55
Thanks: 29
Thanked 0 Times in 0 Posts
gayathri is an unknown quantity at this point
text box

Hi,
I did a php code for inserting and updating elements into the database.
Nw i want to do the coding for, When clicking the submit button, a messagebox with input field get open asking to enter the name.How shall i do this please any1 help me.
gayathri is offline   Reply With Quote
Old 12-07-2012, 09:37 AM   PM User | #2
Custard7A
Regular Coder

 
Custard7A's Avatar
 
Join Date: Jul 2010
Location: Australia
Posts: 269
Thanks: 32
Thanked 32 Times in 32 Posts
Custard7A is an unknown quantity at this point
You can do that with Javascript instead. At that point you are still waiting for the user to enter some data, so you would want them to do so before sending it off to be processed by your PHP script.

It may be more appropriate if the name input field is already avaliable to be filled-out. You should bear in mind that a submit button (in the format of a submit button) will usually be expected to submit the page, not progress to another step.
Custard7A is offline   Reply With Quote
Users who have thanked Custard7A for this post:
gayathri (12-07-2012)
Old 12-07-2012, 10:23 AM   PM User | #3
gayathri
New Coder

 
Join Date: Nov 2012
Location: chennai
Posts: 55
Thanks: 29
Thanked 0 Times in 0 Posts
gayathri is an unknown quantity at this point
I can understand. bt still i dont knw where to set the input field in the code. will u please tell it with an example.
gayathri is offline   Reply With Quote
Old 12-07-2012, 11:11 AM   PM User | #4
Redcoder
Regular Coder

 
Redcoder's Avatar
 
Join Date: May 2012
Location: /dev/couch
Posts: 309
Thanks: 2
Thanked 46 Times in 45 Posts
Redcoder has a little shameless behaviour in the past
You put Javascript code in HTML code. Then set an event trigger that will cause a message box(or prompt) to appear. Then set your PHP code to process the textbox/messagebox/prompt using $_POST.

I don't know whether you know any Javascript as you have not stated but check out documentation on Javascript here:

http://www.w3schools.com/js/default.asp

PHP $_POST:

http://www.w3schools.com/php/php_post.asp

http://php.net/manual/en/reserved.variables.post.php

You have not stated what exactly you know or don't know.
__________________
For professional Hosting and Web design.....


NetEssentials.co.uk
Redcoder is offline   Reply With Quote
Users who have thanked Redcoder for this post:
gayathri (12-10-2012)
Old 12-07-2012, 12:15 PM   PM User | #5
gayathri
New Coder

 
Join Date: Nov 2012
Location: chennai
Posts: 55
Thanks: 29
Thanked 0 Times in 0 Posts
gayathri is an unknown quantity at this point
I knw little bit in java script.
the following is a piece of my code. In this i dnt knw were to add to get input field i text box

Code:
<html>
<head>
<title>QBank</title>
</head>
<body>
<form name="Board" action="boards1.php" method="post">
id :<input type="text" name="sid">
name : <input type="text" name="sname"><br>
<table border="1">
<tr><th>Id</th><th>Name</th></tr>
<?
include("config.php");
$sql1="select * from Boards order by id";
$res1=mysql_query($sql1);
while($row = mysql_fetch_array($res1))
{
echo "<tr><td>$row[0]</td><td>$row[1]</td></tr>";
}
?>
</table>
<input type="submit" value="Save" name="insert" />
<input type="submit" value="update" name="update"/>
<input type="submit" value="clear" name="clr"/>
</form>
</body>
</html>
Code:
<?php
include("config.php");
$id=$_POST['sid'];
$name=$_POST['sname'];
$update=$_POST['update'];
//$save=$_POST['insert'];
echo $update." ".$id." ".$name." ";
/*if(($sav=="Save"))
{
echo "hai";

$sql="insert into Boards(id,name)values($id,'$name')";
$res=mysql_query($sql);
}*/
if(($update=="update"))
{
//echo "hai1";
$sql1="update Boards set name='$name' where id=$id";
echo $sql1;
$res1=mysql_query($sql1);
if($res1)
echo "<script>($res1)</script>";
}
?>
any1 please tell me
gayathri is offline   Reply With Quote
Old 12-08-2012, 12:51 AM   PM User | #6
Custard7A
Regular Coder

 
Custard7A's Avatar
 
Join Date: Jul 2010
Location: Australia
Posts: 269
Thanks: 32
Thanked 32 Times in 32 Posts
Custard7A is an unknown quantity at this point
You should just create another <input type="text"... Creating a pop-up box in Javascript to gain additional data is quite flawed, without efficient fall-backs at least. Some people may have Javascript disabled and your form will then break.
Custard7A is offline   Reply With Quote
Users who have thanked Custard7A for this post:
gayathri (12-10-2012)
Old 12-10-2012, 02:47 AM   PM User | #7
gayathri
New Coder

 
Join Date: Nov 2012
Location: chennai
Posts: 55
Thanks: 29
Thanked 0 Times in 0 Posts
gayathri is an unknown quantity at this point
Thanks Custard7A and Redcoder for ur useful post. With ur ideas i did my code. And its working too. thanks
gayathri is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:59 AM.


Advertisement
Log in to turn off these ads.