Jump to content

Abuda

Members
  • Posts

    11
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    Syria

Abuda's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I hope this belongs to the right sub-forum. I'm gonna be on the move for quite some time, and I was wondering if there was an [almost] ideal portable PHP development environment, which I can treat just like the non-portable counterpart, which will include using Composer, Laravel, etc. With a little research I found http://zwamp.sourceforge.net/ and http://www.codelobster.com, but I'm not sure how efficient they are. Any of you guys use this approach? Thanks.
  2. The following modification works fine. I substituted the "onClick" function with a "onChange", and removed the JS value() function since there was no use for it. <html> <head> <title>Untitled</title> <script language="JavaScript"> function process(val) { if(val == "no") { document.myForm.textbox.disabled = false; document.myForm.textbox2.value = 0; }else{ document.myForm.textbox.disabled = true; document.myForm.textbox2.value = 10; } } </script> </head> <body> <form name="myForm"> <table> <tr> <label> Do you accept </label> <td> <select name="na" onChange="process(this.value);"> <option value="yes"> YES </option> <option value="no"> NO </option> <option value="NA"> NA </option> </select> <input type="text" name="textbox" value="" disabled> <input type="text" name="textbox2" value="10" > </td> </tr> <tr> <td> </td> </tr> </form> </body> </html>
  3. Painfully brief, but helpful thank you. I ended up with this: <?php $size = 13; $font = 'arial.ttf'; $char = 'fffffddddddfffff@gmail.com'; $rect = imagettfbbox($size, 0, $font, $char); $imh = 17; // fixed $imw = $rect[2]; $my_img = imagecreate($imw, $imh); $background = imagecolorallocate( $my_img, 255, 255, 255 ); $text_colour = imagecolorallocate( $my_img, 0, 0, 0 ); $line_colour = imagecolorallocate( $my_img, 128, 255, 0 ); imagecolortransparent($my_img, $background); imagestring( $my_img, 3, 0, 0, $char, $text_colour ); header('Content-Type: image/jpeg'); imagepng( $my_img ); ?> The only problem now emerges from the difference between the number (13) used in line 1 and between the number (3) used in line 13. It's causing extra margin for long strings, and cropping for very long strings. I'll struggle with it for the next few hours and see what pops up. Thanks again.
  4. Hi, I have this tiny file that receives some text via $_GET then returns an image including that text. The problem is, i might send it a very long string which will result in it being cropped. <?php $my_img = imagecreate(100, 30); $background = imagecolorallocate( $my_img, 255, 255, 255 ); $text_colour = imagecolorallocate( $my_img, 0, 0, 0 ); $line_colour = imagecolorallocate( $my_img, 128, 255, 0 ); imagecolortransparent($my_img, $background); imagestring( $my_img, 4, 0, 0, "yellowwwwwwwww", $text_colour ); header('Content-Type: image/jpeg'); imagepng( $my_img ); ?> Is there some way to tell php to set whatever width and height so that my text won't get cropped? Thanks.
  5. Dumb question, turned out that I could place JQuery inside a Javascript function.
  6. Hi, I have this problem, I have an array of images with the same class name, I created a JQuery function that looks like this: $(".delPic").click(function() { // action goes here .... }); The problem is, there is a function in my page that inserts a new similar image (class='delPic') using .insertAfter(). now the function shown above won't work since the new image is inserted after the document is loaded. what do I do ? Thanks.
  7. Copy the code as provided in my last post and paste it into a new form.php. You only have to replace: mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); header('Location: contactthanks.php'); with: echo "OK"; Since you're on a localhost. And you'll see that it works just fine. You'll then need to modify that to appear the way you need, knowing that you can't simply mix codes together, this is what you're doing and that's why you're getting the syntax error. You're missing a curly bracket at the end of your last code, and I don't think this is the only problem, you'll need to be more careful.
  8. Tested. form.php <?php if($_POST['submit']) { // only checking for empty fields, regexp can do a lot more. $error = ""; if( $_POST['name'] == "") { $error .= "<br />- Name field is empty."; } if( $_POST['phone'] == "") { $error .= "<br />- Phone field is empty."; } if( $_POST['email'] == "") { $error .= "<br />- Email field is empty."; } if( $_POST['message'] == "") { $error .= "<br />- Message field is empty."; } $EmailFrom = "example@gmail.com"; $EmailTo = "example@gmail.com"; $Subject = "New Lead!!!"; $name = Trim(stripslashes($_POST['name'])); $phone = Trim(stripslashes($_POST['phone'])); $email = Trim(stripslashes($_POST['email'])); $message = Trim(stripslashes($_POST['message'])); if($error == "") { // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $name; $Body .= "\n"; $Body .= "Phone Number: "; $Body .= $phone; $Body .= "\n"; $Body .= "Email: "; $Body .= $email; $Body .= "\n"; $Body .= "Message: "; $Body .= $message; $Body .= "\n"; // send email mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); header('Location: contactthanks.php'); }else{ echo<<<END <html> <head></head> <body> <form action="form.php" method="POST"> Name: <input type="text" name="name" value="$name"><br /> Phone Number: <input type="text" name="phone" value="$phone"><br /> Email: <input type="text" name="email" value="$email"><br /> Message: <input type="text" name="message" value="$message"><br /> <input type="submit" name="submit"> <p>$error</p> </form> </body> </html> END; } }else{ echo<<<END <html> <head></head> <body> <form action="form.php" method="POST"> Name: <input type="text" name="name" value=""><br /> Phone Number: <input type="text" name="phone" value=""><br /> Email: <input type="text" name="email" value=""><br /> Message: <input type="text" name="message" value=""><br /> <input type="submit" name="submit"> </form> </body> </html> END; } ?> As many have stated, never use Javascript for form validation (Unless you're validating again via a server-side language).
  9. First two lines here are useless. (!$validationOK) will never return TRUE since you already set validationOK to TRUE one line earlier. Am I imagining this?
  10. Thanks a million, results are reasonable now. Edit: I just discovered that the algorithm fails horribly for higher values of $i (20 --> 40). :-(
  11. Hello, Here's the Wikipedia Page explaining how to test a number for primality using the mentioned algorithm. In Short: [tex] M_p = \text2^p - 1 [/tex] [tex] s_i= \begin{cases} 4 & \text{if }i=0; \\ s_{i-1}^2-2 & \text{otherwise.} \end{cases} [/tex] [tex]\color{blue} M_p[/tex] is a prime if and only if: [tex]s_{p-2}\equiv0\pmod{M_p}.[/tex] I tried to interpret that to PHP as the following: <?php for($i = 2; $i < 10; $i++) { // testing from (2^2 - 1) to (2^10 - 1) $s = 4; $m = pow(2, $i) - 1; // define M if($i > 2){ // Start computing $s only if ($i - 2) > 0, otherwise $s remains equal to 4. for($j = 1; $j <= $i - 2; $j++) { // Find S(p-2) $s = (($s * $s) - 2); } } if($s % $m == 0) { echo "<br />$m"; } // Print out detected prime number. } ?> Here's the output: 7 31 255 511 The code is already messing up since 2 of those results are not prime numbers. Any idea where I might have gone wrong? Thanks.
  12. Abuda

    Hi

    Hello everyone, I've been using php for quiet a long time now, still consider myself a newbie, and while searching the internet this forum was just the community I was looking for. I'll enjoy browsing and benefiting from the topics posted in here. Regards, Abuda.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.