hiiiii, i am beginer in php. i want to make a form in which four field there ie name, roll, subject and picture. name and roll must be string and numbers if not then give red box input field and save picture in a folder and also thier is two button, one is submit and other is showlist. when i click on submit button, the data is save into database and when click on showlist, the data is retrieve and show 20 rows as a table .
3 1163
i want to make a form in which four field there ie name, roll, subject and picture. name and roll must be string and numbers if not then give red box input field and save picture in a folder and also thier is two button, one is submit and other is showlist.
that’s an HTML question, not a PHP question.
when i click on submit button, the data is save into database and when click on showlist, the data is retrieve and show 20 rows as a table .
what have you tried?
remember, we’re not a free coding service, we’re a help forum.
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
<html>
-
<head>
-
<meta http-equiv="content-type" content="text/html; charset=windows-1251">
-
<style>
-
.errText {
-
font-family: Arial;
-
font-size: 10px;
-
color: #CC0000;
-
text-decoration: none;
-
font-weight: normal;
-
}
-
a{
-
text-decoration: none;
-
}
-
</style>
-
<title></title>
-
</head>
-
<?php
-
-
$con=mysqli_connect("localhost","root","");
-
if (mysqli_connect_errno())
-
{
-
echo "Failed to connect to MySQL: " . mysqli_connect_error();
-
}
-
-
mysql_select_db("test") OR DIE ("Unable to select db".mysql_error());
-
-
$sql = "CREATE TABLE details (
-
pid int primary key not null auto_increment,
-
name CHAR(30),
-
roll INT(10).
-
subject VATCHAR(50),
-
picture longblob)";
-
-
-
$errName = "";
-
$errroll = "";
-
-
$name=$_POST["name"];
-
$roll=$_POST["roll"];
-
$subject=$_POST["subject"];
-
$picture=$_POST["picture"];
-
-
-
if($_POST["ac"]=="login"){
-
-
if(preg_match("/^[A-Z][a-zA-Z -]+$/", $name) === 0)
-
$errName = '<p class="errText">Name must be from letters, dashes, spaces and must not start with dash</p>';
-
-
if(preg_match("/^[0-9]+$/", $roll) === 0)
-
$errroll = '<p class="errText">roll must be only numbers </p>';
-
-
}
-
-
if (!isset($_POST['submit'])) {
-
-
$allow = array("jpg", "jpeg", "png");
-
-
$todir = 'uploads/';
-
-
if ( !!$_FILES['file']['tmp_name'] )
-
{
-
$ext = explode('.', strtolower( $_FILES['file']['picture']) );
-
-
if ( in_array( $ext, $allow) )
-
{
-
if ( move_uploaded_file( $_FILES['file']['tmp_name'], $todir . basename($_FILES['file']['picture'] ) ) )
-
{
-
echo "Upload: " . $_FILES["file"]["picture"] . "<br>";
-
echo "Type: " . $_FILES["file"]["type"] . "<br>";
-
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
-
echo "Stored in: " . $_FILES["file"]["tmp_name"];
-
}
-
}
-
else
-
{
-
echo "Invalid file";
-
}
-
}
-
-
$result="INSERT INTO details (name,roll,subject,picture) VALUES ('$name', '$roll', '$subject', '$picture')";
-
if (!mysqli_query($con,$result))
-
{
-
echo "there was some error";
-
}
-
?>
-
<body>
-
<center>
-
<form name="main" action="<?php $PHP_SELF ?>" method="POST">
-
<input type="hidden" name="ac" value="login">
-
<table width="500" border="0" cellpadding="4" cellspacing="0" bordercolor="#000000" bgcolor="#EDEFF1">
-
<tr align="center" bgcolor="#FD9003">
-
<td colspan="2" bgcolor="#A6B39D">Registration Form</td>
-
</tr>
-
<tr>
-
<td>Name:</td>
-
<td>
-
<input name="name" type="text" size="50" maxlength="100" value="<?php echo $_POST['name']; ?>"/>
-
<?php if(isset($errName)) echo $errName; ?>
-
</td>
-
</tr>
-
<tr>
-
<td>Roll:</td>
-
<td>
-
<input name="roll" type="text" size="50" maxlength="10" value="<?php echo $_POST['roll']; ?>"/>
-
<?php if(isset($errroll)) echo $errroll; ?>
-
</td>
-
</tr>
-
<tr>
-
<td>Subject:</td>
-
<td>
-
<input name="subject" type="text" size="50" />
-
</td>
-
</tr>
-
<tr>
-
<td>Picture:</td>
-
<td>
-
<input name="picture" type="file" />
-
</td>
-
</tr>
-
<td> </td>
-
<td><input type="submit" name="Submit" value="Submit"></td>
-
<td><a href="test2.php"><input type="button" name="Submit" value="Show List" /></a></td>
-
</tr>
-
</table>
-
</form>
-
</center>
-
</body>
-
<?php
-
}
-
?>
-
</html>
What's wrong in above code
What's wrong in above code
you’re mixing mysql and mysqli.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: vishal |
last post by:
hello friends
i have one php script which generates html page containing form. what i
want is submit this form using php script.
pls give me some idea that how can i submit form using php...
|
by: Chris |
last post by:
Dear all,
I would like to figure out a way to add controls to a form using specs
stored in a table. Any assistance in fleshing this idea out would be
greatly appreciated. I'm using VB6.
...
|
by: btopenworld |
last post by:
I am submitting a form using an image as the link to a js file.
The image calls a js function which checks fields- issuing alerts for
errors - if no errors it then submits the form.
I would like...
|
by: Justin Sane |
last post by:
I haven't been able to select a form using getElementById. I only can
select a form using the "name" property of the <form> tag. Is there
another way to select a form, or is it even possible to use...
|
by: Cc |
last post by:
hi,
how do I make form background colour transparent when I set border style to
none?
|
by: tmaster |
last post by:
Within a class, can I create a property that is a listview? Here's what I
tried, but it doesn't seem to work:
'------------ create property to give the second form access to the first
form's...
|
by: Michael Creager |
last post by:
I am using VB NET 2002. How can I programmatically create a new windows
form using the value of a string variable as the name of the new form?
Public FrmName As String = "MDIChildFrm1"
Public...
|
by: listerofsmeg01 |
last post by:
I think I probably know that answer, but I will ask anyway.
Is it possible to submit a form using a standard anchor link, rather
than a submit button?
The reason I ask is that I have a standard...
|
by: noks |
last post by:
Hi guys
Can you please help me with the syntax to save data within a form using tblA to tblB (whicheva changes i make on the form, i want saved on both tables)
i've tried this whenever i click...
|
by: Palehorse |
last post by:
I'd like to apologize upfront for me saying "I'm not a programer", I'm sure you all hear this a hundred times a day. Unfortunately, in this case, it's true. I've been working on trying to figure out...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |