The Arcive of vBulletin Modifications Site. |
|
|
#1
|
|||
|
|||
|
Hi, I'm trying to create a form where users fill out a form to edit users vBCredits amount (Thinking they can see it by mistake) however upon submission it'll send them to rick roll as well as make a post within a specified thread from my userID letting me know who tried it and their form inputs
This is what I have so far but it doesn't work, any help would be appriciated. I have a plugin with the hook "newpost_process" PHP Code:
HTML Code:
<div class="container1"> <div class="form-container"> <form action="newthread.php?do=postthread&f=19" method="post" onsubmit="return validateForm()"> <h1 class="custom">Administrators Token Adjustment Form</h1> <div class="label-container"> <div class="form-field"> <label for="username"> <span>Username:</span> </label> <input type="text" id="username" name="username" placeholder="Enter recipient's Username" required> </div> <div class="form-field"> <label for="give_or_take"> <span>Do you want to give or take tokens?</span> </label> <div> <label for="give"><input type="radio" id="give" name="give_or_take" value="give" required> Give</label> <label for="take"><input type="radio" id="take" name="give_or_take" value="take" required> Take</label> </div> </div> <div class="form-field"> <label for="tokens"> <span>Token Amount</span> </label> <input type="number" id="tokens" name="tokens" placeholder="Enter the number of tokens" min="0" max="25000" required> </div> <div class="form-field"> <label for="reason"> <span>Adjustment Reason (max 100 characters):</span> </label> <textarea id="reason" name="reason" placeholder="Enter the reason for the adjustment (max 100 characters)" maxlength="100" required></textarea> </div> <div class="button-container"> <button type="submit" onclick="validateForm(event)">Submit</button> <button type="reset">Reset</button> </div> </div> </form> </div> </div> </body> (If you're interested in the form that just redirects, then see the code below - however it's only the above I need help with - so that it posts a reply to a specific thread using either a specific ID or the userID of the person who submitted the form (I don't mind either way, probs best for a specific ID though rather than theirs as long as it displays in the new post who submitted the form) Code:
<!DOCTYPE html>
<html>
<head>
<title>Token Request Form</title>
<style>
.form-container {
flex: 1;
padding: 20px;
box-sizing: border-box;
flex-direction: row-reverse;
display: inline-flex;
flex-wrap: wrap;
align-content: flex-start;
flex-direction: row;
align-items: center;
font-family: Arial, sans-serif;
background-color: #ffffff;
padding: 20px;
border-radius: 10px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
}
h1.custom {
text-align: center;
}
.label-container {
font-weight: bold;
margin-top: 10px;
display: flex;
width: 100%;
}
.label-container span {
margin-bottom: 5px;
}
input[type="text"], input[type="number"], textarea {
padding: 10px;
margin: 10px;
border-radius: 5px;
border: 1px solid #ccc;
font-size: 16px;
width: 50%;
}
input[type="text"]:focus, input[type="number"]:focus, textarea:focus {
outline: none;
border-color: #008CBA;
}
input[type="number"] {
-webkit-appearance: none;
-moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
-webkit-appearance: none;
}
textarea {
height: 50px;
}
.button-container {
display: flex;
justify-content: center;
}
.button-container button[type="submit"] {
margin-right: 5px;
}
.error-message {
color: red;
font-size: 14px;
margin-top: 10px;
text-align: center;
}
.button-container button[type="submit"] {
margin-right: 5px;
background-color: #008CBA;
color: #fff;
border: none;
border-radius: 5px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
.button-container button[type="submit"]:hover {
background-color: #006B8F;
}
.button-container button[type="reset"] {
background-color: #ccc;
color: #000;
border: none;
border-radius: 5px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
.container1 {
display: flex;
}
.form-container {
flex: 1;
padding: 20px;
box-sizing: border-box;
}
.label-container {
display: flex;
flex-direction: column;
}
.label-container > label {
margin-bottom: 10px;
}
.error {
border-color: red;
}
.button-container button[type="reset"]:hover {
background-color: #bbb;
}
.form-field {
display: flex;
flex-direction: column;
margin-bottom: 10px;
}
.form-field label {
margin-bottom: 5px;
}
#rightbox55 {
position: absolute;
right:20%;
}
@media screen and (max-width: 1200px) {
#rightbox55 {
position: inherit;
left:50%;
}
</style>
</head>
<body>
<div class="container1">
<div class="form-container">
<form onsubmit="return validateForm()">
<h1 class="custom"> Administrators Token Adjustment Form</h1>
<div class="label-container">
<div class="form-field">
<label for="username">
<span>Username:</span>
</label>
<input type="text" id="username" name="username" placeholder="Enter recipient's Username" required>
</div>
<div class="form-field">
</label>
<div class="form-field">
<label for="give_or_take">
<span>Do you want to give or take tokens?</span>
</label>
<div>
<label for="give"><input type="radio" id="give" name="give_or_take" value="give" required> Give</label>
<label for="take"><input type="radio" id="take" name="give_or_take" value="take" required> Take</label>
</div>
</div>
<div class="form-field">
<label for="tokens">
<span>Token Amount</span>
</label>
<input type="number" id="tokens" name="tokens" placeholder="Enter the number of tokens" min="0" max="25000" required>
</div>
<div class="form-field">
<label for="reason">
<span>Adjustment Reason (max 100 characters):</span>
</label>
<textarea id="reason" name="reason" placeholder="Enter the reason for the adjustment (max 100 characters)" maxlength="100" required></textarea>
</div>
<div class="button-container">
<button type="submit" onclick="validateForm(event)">Submit</button>
<button type="reset">Reset</button>
</div>
</div>
</form>
</div>
</div>
</body>
<script>
function validateForm(event) {
event.preventDefault();
const form = document.querySelector('form');
const inputs = form.querySelectorAll('input[required], textarea[required]');
let isFormValid = true;
inputs.forEach((input) => {
if (!input.value) {
input.classList.add('error');
isFormValid = false;
} else {
input.classList.remove('error');
}
});
if (!isFormValid) {
} else {
window.location.href = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";
}
}
</script>
</body>
|
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|